vcbertini
asked on
Inline C# Script Not working
I am trying to do a client-side script to make a row appear/disappear when the users clicks on a radio button. I was going to do this in JavaScript, but got to reading about putting inline C# into the code, so thought I would try that for consistency (also some people turn off JavaScript in their browser).
Anyhow, I can't get it to work - have tried modifying it every-which-way and it is either not firing at all (current state) or it is giving me an error: "Microsoft JScript runtime error: 'ShowRows' is undefined.
The script code is as follows:
...and this is the portion of the code containing the controls that call it:
Anyhow, I can't get it to work - have tried modifying it every-which-way and it is either not firing at all (current state) or it is giving me an error: "Microsoft JScript runtime error: 'ShowRows' is undefined.
The script code is as follows:
<head id="Head1" runat="server">
<script type="text/C#" runat="server" language="C#">
protected void ShowRows()
{
if (rbCategory.Checked)
{
trLocation.Visible = true;
trSortOrder.Visible = false;
txtSortOrder.Text = "0";
ddlSubcategory.SelectedIndex = -1;
}
else
{
trSortOrder.Visible = true;
trLocation.Visible = false;
cbSchaumburg.Checked = false;
ddlPrograms.SelectedIndex = -1;
}
}
</script>
</head>
...and this is the portion of the code containing the controls that call it:
<tr>
<td align="left" valign="top" colspan="2"><p><strong>The
Degree/Certificate/Credential/Concentration named above:</strong></p>
<asp:RadioButton ID="rbCategory" runat="server" GroupName="degreeType"
Text="belongs to this Program of Study: " Checked="True" TabIndex="3" onClick="<%ShowRows();%>" />
<asp:DropDownList ID="ddlPrograms" runat="server" TabIndex="4">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvPrograms" runat="server"
ControlToValidate="ddlPrograms" Display="Dynamic" Enabled="False"
ErrorMessage="RequiredFieldValidator" Font-Bold="True" ForeColor="Red"
SetFocusOnError="True">* Required</asp:RequiredFieldValidator>
<br />
<asp:RadioButton ID="rbSubcategory" runat="server" GroupName="degreeType" Text="is a Subcategory of: " onClick="<%ShowRows();%>"
TabIndex="5" />
<asp:DropDownList ID="ddlSubcategory" runat="server" TabIndex="6">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvSubcategory" runat="server"
ControlToValidate="ddlSubcategory" Display="Dynamic" Enabled="False"
Font-Bold="True" ForeColor="Red"
SetFocusOnError="True" Text="* Required"></asp:RequiredFieldValidator>
<br />
<em><span class="style1">* applicable usually to
Concentrations, Emphases, Theses, etc.</span></em></td>
</tr>
<tr id="trSortOrder" runat="server">
<td align="left" valign="top"> </td>
<td>
<strong>Sort Order:</strong>
<asp:TextBox ID="txtSortOrder" runat="server" Columns="3" MaxLength="2"
TabIndex="7">1</asp:TextBox>
<asp:RequiredFieldValidator ID="rfvSortOrder" runat="server"
ControlToValidate="txtSortOrder" Display="Dynamic" Enabled="False"
Font-Bold="True" ForeColor="Red" SetFocusOnError="True" Text="* Required for subcategories"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="rvSortOrder" runat="server" Display="Dynamic"
Text="Value must be > 0" MaximumValue="10" MinimumValue="1"
SetFocusOnError="True" ControlToValidate="txtSortOrder" Font-Bold="True"
ForeColor="Red"></asp:RangeValidator>
</td>
</tr>
<tr id="trLocation" runat="server">
<td align="left" valign="top"> </td>
<td>
<asp:CheckBox ID="cbSchaumburg" runat="server"
Text="This program is offered at the Schaumburg campus" TabIndex="8" />
</td>
</tr>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER