不使用jQuery或Javascript,因为这是一个现有网站的修复,它不是这样设计的。我已经达到了这样一个点,当DropDownList被选中并且它是postBack时,我执行我的逻辑,将textBox readOnly状态设置为true或false。我现在的问题是selectValue不一致。selct字段中显示的内容与发回页面的内容不同。假设我有None、5.00、10.00、15.00、20.00作为我的选择。我首先选择10.00,然后我选择20.00,它显示10.00。它回发先前的select值。整个网站都是从代码后台页面编写的。aspx页面完全是从.vb页面编写的。所有内容都被写入asp标签。以下是代码;
If Page.IsPostBack Then
If product_option_is_required > 0 then
myTextBox.ReadOnly= true
Else
myTextBox.ReadOnly= false
End if
For Each child_control As Control In productOptions.Controls
If TypeOf child_control Is DropDownList Then
Dim child_ddl As DropDownList = child_control
tempName = products.getProductDependant("product_option_name",product_option_id)
tempSelectText = products.getProductSelectDependant("product_option_detail_name",child_ddl.SelectedValue)
priceDependant.Text ="here" & child_ddl.ID & " " & child_ddl.SelectedIndex & " " & child_ddl.SelectedValue & " --" & tempSelectText
If child_ddl.Text = "None" then
myTextBox.ReadOnly = true
myTextBox.Text = "If selected above enter name"
Else
myTextBox.ReadOnly = false
myTextBox.Text = ""
End if
End If
next
End if发布于 2013-01-26 05:41:29
在您的代码中,您像使用字符串值一样使用dependantProd。
dependantProd = tempName.Replace(" ", "_") & "_" & product_option_id如果它是字符串,你不能这样做-
如果dependantProd.SelectedIndex >0,则为
此外,如果您动态创建一个控件,则需要在回发时进行检索。否则,您将无法检索它们的投递值。
https://stackoverflow.com/questions/14530268
复制相似问题