I have a modal popup with a formview with a default mode of Edit. The controls inside the form are bound to data. I have JavaScript that shows a textbox and a label only if a certain value is selected from a dropdownlist. I want to do this on load also.
<tr>
<td align="left">
<asp:DropDownList
ID="ddl5"
AutoPostBack ="false"
onchange = showifother('12',this.value);"
SelectedValue='<%# Eval("event_type") %>'
runat="server"
DataSourceID="SqlDataSource5"
AppendDataBoundItems ="true"
DataTextField="Description"
DataValueField="ID">
<asp:ListItem
Selected="True"
style="color:gray"
Value="" >Causes of Damage</asp:ListItem>
</asp:DropDownList>
<tr id="treditpropdamage" style="display:none">
<td align="left">
<asp:TextBox
ID="txt2"
runat="server"
TextMode ="MultiLine"
ondatabinding="TextBox2_DataBinding"
ValidationGroup ="Editprop"
Text = '<%# Bind("bounddata") %>'></asp:TextBox>
</td>
</tr>
function showifother(num, value)
{
var treditpropdamage = document.getElementById('treditpropdamage');
if (num == '12')
{
if (value == '4')
{
treditpropdamage.style.display = '';
}
else
{
treditpropdamage.style.display = 'none';
}
}
}
How can I set the tr tag to visible if 4 is the value of the bound value for the Dropdownlist in C#? Adding Runat="server" is not an option because I want to access the controls in JavaScript via document.getelementbyid