0

I have an HTML button control and on click I want to call a asp.net button click event. I want to know how can I generate a click event handler in code behind?

when I am trying to do this in the Page_Load event:

 btnSearch.Click += new EventHandler();

I get error:

btnSearch doesnot exist in the current context

Here is the HTML:

<input type="button" class="SmallButton ButtonSpacingAfter" value="Search" id="btnSearch" onserverclick="Button1_Click"/>

1 Answer 1

1

You need to convert it to a server side control by specifying runat="server" .

<input id="foo "runat="server" type="button" onserverclick="foo_OnClick" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.