Help needed for ServerClick function don't start

  • Thread starter Thread starter David Jia
  • Start date Start date
D

David Jia

Hi, I have a problem in VS2003 and .Net 1.1 as below:

I put a HTML submit button control and label it as "run @ server"

My purpose is that when click this button, system will check the input
fields' value

so I write on form's onsubmit method is "return checkfield()"

BUT, after I compose some code in button's server click method in C# code
behind the aspx file, when I click the "submit" button , the server_click
code never run.

How can I solve this problem, thanks!!
 
Some Addtional information:
I have read some example in MSDN
seems the code I wrote is as the same as the example and a little diffence
is:
Example in MSDN place the Server_click in aspx file
The code I wrote is in cs file beind the aspx

What's the reason?
 
Does the button refer to your event properly for the click event? Something
you could do instead is override the init event of the page, then set the
button's click event to your event handler there such as:

Button1.Click+=new EventHandler(Button1_Click);
 
I have found this two sentences in my Initpage, does it work ?

private void InitializeComponent()
{
this.btnEdit.ServerClick += new
System.EventHandler(this.btnEdit_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public void btnEdit_ServerClick(object sender, System.EventArgs e)
{
// nothing to do now
Response.Write("<script> alert('yes'); </script>");
VideoFile.PostedFile.SaveAs("c:\\test.pp");

}
 
It is not working, please help me !! help!!
David Jia said:
I have found this two sentences in my Initpage, does it work ?

private void InitializeComponent()
{
this.btnEdit.ServerClick += new
System.EventHandler(this.btnEdit_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public void btnEdit_ServerClick(object sender, System.EventArgs e)
{
// nothing to do now
Response.Write("<script> alert('yes'); </script>");
VideoFile.PostedFile.SaveAs("c:\\test.pp");

}
 
Back
Top