S
Soul
Hi,
I have .aspx page code in C#, which contain a sample registration form.
There are help Button controls beside all fields, when user click on the
help button, there will be an explanation text display in a Label control.
There is a also a submit Button control at the bottom of the page for user
to submit the registration form. Both Button controls are calling different
fucntion.
There are some RequiredFieldValidator controls responsible for different
TextField controls. Things are running fine except, when user trigger any
help Button control, RequiredFieldValidator controls will also try to
validate those TextField controls.
Is there a way to code so that the RequiredFieldValidator will only validate
when user click on the submit Button control?
---
<%@ Page Language="C#" %>
<script runat="server">
void ButtonHelp_Click(object sender, EventArgs e) {
switch (((Button)sender).ID)
{
case "ButtonHelpTitle":
LabelHelpPanel.Text = "Select your title designation.";
break;
......
......
default:
break;
}
}
void FormSubmit(object sender, EventArgs e)
{
......//Change the text of lblResult
}
</script>
<html>
<head>
<link href="../global_res/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="Layer1" style="WIDTH: 600px">
<table width="100%">
<tbody>
<tr>
<td>
<form runat="server">
<table>
<tbody>
<tr>
<td>
Title:</td>
<td>
<aspropDownList
id="DropDownListTitle" runat="server" CssClass="aspControl">
<asp:ListItem
Value="Mr">Mr</asp:ListItem>
<asp:ListItem
Value="Dr">Dr</asp:ListItem>
<asp:ListItem
Value="Sir">Sir</asp:ListItem>
<asp:ListItem
Value="Mrs">Mrs</asp:ListItem>
<asp:ListItem
Value="Ms">Ms</asp:ListItem>
<asp:ListItem
Value="Mdm">Mdm</asp:ListItem>
</aspropDownList>
</td>
<td>
<asp:Button id="ButtonHelpTitle"
onclick="ButtonHelp_Click" runat="server" ToolTip="Click for help." Text="?"
BorderStyle="Solid" BackColor="Silver" BorderColor="Gray"></asp:Button>
</td>
</tr>
<tr>
<td>
First name:</td>
<td>
<asp:TextBox
id="TextBoxFirstName" runat="server" CssClass="aspControl"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidatorFirstName" runat="server" ErrorMessage="You must
specify your first name." ControlToValidate="TextBoxFirstName"
Display="Dynamic" Enabled="False"></asp:RequiredFieldValidator>
</td>
<td>
<asp:Button
id="ButtonHelpFirstName" onclick="ButtonHelp_Click" runat="server"
ToolTip="Click for help." Text="?" BorderStyle="Solid" BackColor="Silver"
BorderColor="Gray"></asp:Button>
</td>
</tr>
<tr>
<td>
<asp:button id="ButtonSubmit"
onclick="FormSubmit" runat="server" text="Submit"></asp:button>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</form>
</td>
<td class="tdTop">
<table class="blueTable">
<tbody>
<tr>
<td align="middle" bgcolor="#5493d8"
colspan="3">
<b>Help Panel</b></td>
</tr>
<tr>
<td>
<asp:Label id="LabelHelpPanel"
runat="server" cssclass="labelHelpPanel">Click on "?"
to display help information about
the field next to it.</asp:Label></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<asp:Label id="lblResult" runat="server" forecolor="Fuchsia"
font-name="Times New Roman" font-size="15pt">Test</asp:Label>
</div>
</body>
</html>
Thank you.
I have .aspx page code in C#, which contain a sample registration form.
There are help Button controls beside all fields, when user click on the
help button, there will be an explanation text display in a Label control.
There is a also a submit Button control at the bottom of the page for user
to submit the registration form. Both Button controls are calling different
fucntion.
There are some RequiredFieldValidator controls responsible for different
TextField controls. Things are running fine except, when user trigger any
help Button control, RequiredFieldValidator controls will also try to
validate those TextField controls.
Is there a way to code so that the RequiredFieldValidator will only validate
when user click on the submit Button control?
---
<%@ Page Language="C#" %>
<script runat="server">
void ButtonHelp_Click(object sender, EventArgs e) {
switch (((Button)sender).ID)
{
case "ButtonHelpTitle":
LabelHelpPanel.Text = "Select your title designation.";
break;
......
......
default:
break;
}
}
void FormSubmit(object sender, EventArgs e)
{
......//Change the text of lblResult
}
</script>
<html>
<head>
<link href="../global_res/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="Layer1" style="WIDTH: 600px">
<table width="100%">
<tbody>
<tr>
<td>
<form runat="server">
<table>
<tbody>
<tr>
<td>
Title:</td>
<td>
<aspropDownList
id="DropDownListTitle" runat="server" CssClass="aspControl">
<asp:ListItem
Value="Mr">Mr</asp:ListItem>
<asp:ListItem
Value="Dr">Dr</asp:ListItem>
<asp:ListItem
Value="Sir">Sir</asp:ListItem>
<asp:ListItem
Value="Mrs">Mrs</asp:ListItem>
<asp:ListItem
Value="Ms">Ms</asp:ListItem>
<asp:ListItem
Value="Mdm">Mdm</asp:ListItem>
</aspropDownList>
</td>
<td>
<asp:Button id="ButtonHelpTitle"
onclick="ButtonHelp_Click" runat="server" ToolTip="Click for help." Text="?"
BorderStyle="Solid" BackColor="Silver" BorderColor="Gray"></asp:Button>
</td>
</tr>
<tr>
<td>
First name:</td>
<td>
<asp:TextBox
id="TextBoxFirstName" runat="server" CssClass="aspControl"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidatorFirstName" runat="server" ErrorMessage="You must
specify your first name." ControlToValidate="TextBoxFirstName"
Display="Dynamic" Enabled="False"></asp:RequiredFieldValidator>
</td>
<td>
<asp:Button
id="ButtonHelpFirstName" onclick="ButtonHelp_Click" runat="server"
ToolTip="Click for help." Text="?" BorderStyle="Solid" BackColor="Silver"
BorderColor="Gray"></asp:Button>
</td>
</tr>
<tr>
<td>
<asp:button id="ButtonSubmit"
onclick="FormSubmit" runat="server" text="Submit"></asp:button>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</form>
</td>
<td class="tdTop">
<table class="blueTable">
<tbody>
<tr>
<td align="middle" bgcolor="#5493d8"
colspan="3">
<b>Help Panel</b></td>
</tr>
<tr>
<td>
<asp:Label id="LabelHelpPanel"
runat="server" cssclass="labelHelpPanel">Click on "?"
to display help information about
the field next to it.</asp:Label></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<asp:Label id="lblResult" runat="server" forecolor="Fuchsia"
font-name="Times New Roman" font-size="15pt">Test</asp:Label>
</div>
</body>
</html>
Thank you.