P
Papanii Okai
I have a discussion forum page where, a user can add a new topic thread to
the list of threads. Now to ensure that a user supplies a title and content
to this form, I have two client side RequiredFiledvalidators "titleCheck"
and "messageCheck". Now I also have a cancel button on the page that simply
discards everything and closes the addNewThread window. But for some reason
it doesn't work. Whenever I click the cancel button the client side
validators fire.
The cancel button is a <asp:ImageButton>. Below is the code in the .aspx
file
/// code in .aspx file..///
<asp:ImageButton ID="ImageButton2" runat="server"
ImageUrl="~/images/CancelButton.gif" CommandName="cancel"
OnCommand="buttonExecute"
onmouseover="this.src='../images/CancelOverButton.gif';"
onmouseout="this.src='../images/CancelButton.gif';"/>
Below is the c# function that handles the click events..
///code///
protected void buttonExecute(object sender, CommandEventArgs e)
{
switch (e.CommandName)
{
case "add":
try
{
forum newThread = new forum(Label1.Text,
TitleTextBox.Text);
newThread.insertThreadTopic();
Response.Write("<script>window.close();</script>");
}
catch (Exception err)
{
System.Diagnostics.Debug.WriteLine("Insert new thread
Error");
System.Diagnostics.Debug.WriteLine(err.ToString());
}
break;
case "cancel":
Response.Write("<script>window.close();</script>");
break;
default:
ErrorLabel.Visible = true;
break;
}
}
Suggestion will be appreciated..
--Papanii
the list of threads. Now to ensure that a user supplies a title and content
to this form, I have two client side RequiredFiledvalidators "titleCheck"
and "messageCheck". Now I also have a cancel button on the page that simply
discards everything and closes the addNewThread window. But for some reason
it doesn't work. Whenever I click the cancel button the client side
validators fire.
The cancel button is a <asp:ImageButton>. Below is the code in the .aspx
file
/// code in .aspx file..///
<asp:ImageButton ID="ImageButton2" runat="server"
ImageUrl="~/images/CancelButton.gif" CommandName="cancel"
OnCommand="buttonExecute"
onmouseover="this.src='../images/CancelOverButton.gif';"
onmouseout="this.src='../images/CancelButton.gif';"/>
Below is the c# function that handles the click events..
///code///
protected void buttonExecute(object sender, CommandEventArgs e)
{
switch (e.CommandName)
{
case "add":
try
{
forum newThread = new forum(Label1.Text,
TitleTextBox.Text);
newThread.insertThreadTopic();
Response.Write("<script>window.close();</script>");
}
catch (Exception err)
{
System.Diagnostics.Debug.WriteLine("Insert new thread
Error");
System.Diagnostics.Debug.WriteLine(err.ToString());
}
break;
case "cancel":
Response.Write("<script>window.close();</script>");
break;
default:
ErrorLabel.Visible = true;
break;
}
}
Suggestion will be appreciated..
--Papanii