开发者

onclick unable to do anything

C#

protected void btnS开发者_JS百科ubmit_Click(object sender, ImageClickEventArgs e)
{

//I want to do something here as simple as this below with onClick
label1.Text = "hi";

}

ASP.NET

<asp:ImageButton id="OBBtn_Save" runat="server" OnClick="btnSubmit_Click" 
  ImageUrl="images/buttons/submit.gif"/>


You could use simple html controls:

<input type="image" onclick="javascript:lbl.value='hi'" />
<input id="lbl" type="text" />


check the page directive in the aspx file, verify that the codebehind file is pointing to the right file, and that the class that it inherits is also correct.

Capitalization is important.

another possibility is the wrong dll files is the solution.

Clean the solution then rebuild.

If you want to make sure the event is wired,
all you have to do is += the Event handler in the OnInit method. Then you are sure it was created.

the Downside is if you do this you will also need to -= the event handler in the OnUnload method to prevent memory leaks.

But at least the wire works. and Its in code so you can find all references on it should the time arise.


Do you have any validators in the page? It could be as simple as your page not posting at all because of a validation error. I know I've done it before in the past.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜