Help needed for ServerClick function don't start

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!!
 
D

David Jia

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?
 
M

Mark Fitzpatrick

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);
 
D

David Jia

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");

}
 
D

David Jia

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");

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top