question about HTML control with runat="server"

B

Bob

Hi,

in aspx file, i defined this:

<input id="Button2" type="button" value="button" runat="server"
onclick="klik()"/>

This 'onclick' event is a clientclick (starting the Javascript function
"klik()" ).
I want to do a 'server onclick', just like the <asp:Button> control, but it
doesn't appear in the Intellisense nor in code-behind.

My question is:
is it possible to do an onclick event on the server?
If yes: how?
If no: what's the purpose of using an HTML input control with
runat="server"? What's the difference with a HTML input control not running
on the server (except it runs on the server), since it's not possible to
'onclick' on the server?

Thanks
Bob
 
B

bruce barker

when you put a runat=server on an html control, it means the codebehind
can access the control and its properties. except for a small list of
html control, most end up as a generic html control. (asp.net does
support all input button varients).

in your case the <input type="button"> does not postback normally. it an
html control that only fires a client click in the browser. you can
cause a postback with client code or switch to type=submit which does
perform a browser postback. in this case you use onserverclick to
respond in the codebehind.


-- bruce (sqlwork.com)
 
B

Bob

Thanks

bruce barker said:
when you put a runat=server on an html control, it means the codebehind
can access the control and its properties. except for a small list of html
control, most end up as a generic html control. (asp.net does support all
input button varients).

in your case the <input type="button"> does not postback normally. it an
html control that only fires a client click in the browser. you can cause
a postback with client code or switch to type=submit which does perform a
browser postback. in this case you use onserverclick to respond in the
codebehind.


-- bruce (sqlwork.com)
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top