473,587 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Onclick Event won't fire for an HTML button with runat="server"

Hello,

I have a standard HTML button on an aspx web form that I have set to
runat server. The button is named reset1 and its tag is as follows:

<INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset"
value="Reset" name="btnReset1 " runat="server">

Using Interdev I then double click the button in design view and in the
code behind page (aspx.vb) have the following:

Private Sub btnReset1_Serve rClick(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnReset1.Serve rClick
Response.Write( "<SCRIPT LANGUAGE='javas cript'>")
Response.Write( "alert('hi' )")
Response.Write( "</SCRIPT>")
End Sub

All my <ASP:OBJECTS> run fine, but NOTHING happens when I click this
one button. I have tried adding different onclick events to call the
code behind without success. What do I need to do to get this button
to fire the server-side code?

Thanks,
Ryan

Nov 19 '05 #1
4 6489
Do you want to reset the form and post back?
In this case change the type of the button to "button" instead of "reset".
Then in HTML view of the page, do the following:
Add an onclick event for the Java Script, so it should look something like
this
<INPUT onclick="DoTheR eset();" id="Reset1" ......
Note the semi-colon after the function name, because it is runat server, MS
will add more Java script for postback, else you will get an error.
Then add Java script right to the end of the page
function DoTheReset() {
Form1.reset();
}

Your script will run first, then the MS script to do the postback.
"Ryan" <ry************ @kp.org> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello,

I have a standard HTML button on an aspx web form that I have set to
runat server. The button is named reset1 and its tag is as follows:

<INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset"
value="Reset" name="btnReset1 " runat="server">

Using Interdev I then double click the button in design view and in the
code behind page (aspx.vb) have the following:

Private Sub btnReset1_Serve rClick(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnReset1.Serve rClick
Response.Write( "<SCRIPT LANGUAGE='javas cript'>")
Response.Write( "alert('hi' )")
Response.Write( "</SCRIPT>")
End Sub

All my <ASP:OBJECTS> run fine, but NOTHING happens when I click this
one button. I have tried adding different onclick events to call the
code behind without success. What do I need to do to get this button
to fire the server-side code?

Thanks,
Ryan

Nov 19 '05 #2
Hi Chris,

Yes, this is what I am looking to do. The problem with the different
approaches I have tried so far is that I am trying to get to a
completely clean page...pre-databinding. I have tried clearing the all
the fields using javascript then clearing the view state using an ASP
Button. My data comes back as if I had never cleared it. It seems to
remember when it reposts. (I just called ViewState.clear ). Will the
method below work to restore a blank slate page (pre-databind)...I wish
they had a data.unbind!!!

Thanks,
Ryan

Chris Botha wrote:
Do you want to reset the form and post back?
In this case change the type of the button to "button" instead of "reset".
Then in HTML view of the page, do the following:
Add an onclick event for the Java Script, so it should look something like
this
<INPUT onclick="DoTheR eset();" id="Reset1" ......
Note the semi-colon after the function name, because it is runat server, MS
will add more Java script for postback, else you will get an error.
Then add Java script right to the end of the page
function DoTheReset() {
Form1.reset();
}

Your script will run first, then the MS script to do the postback.
"Ryan" <ry************ @kp.org> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello,

I have a standard HTML button on an aspx web form that I have set to
runat server. The button is named reset1 and its tag is as follows:

<INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset"
value="Reset" name="btnReset1 " runat="server">

Using Interdev I then double click the button in design view and in the
code behind page (aspx.vb) have the following:

Private Sub btnReset1_Serve rClick(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnReset1.Serve rClick
Response.Write( "<SCRIPT LANGUAGE='javas cript'>")
Response.Write( "alert('hi' )")
Response.Write( "</SCRIPT>")
End Sub

All my <ASP:OBJECTS> run fine, but NOTHING happens when I click this
one button. I have tried adding different onclick events to call the
code behind without success. What do I need to do to get this button
to fire the server-side code?

Thanks,
Ryan


Nov 19 '05 #3
Hi Chris,

Yes, this is what I am looking to do. The problem with the different
approaches I have tried so far is that I am trying to get to a
completely clean page...pre-databinding. I have tried clearing the all
the fields using javascript then clearing the view state using an ASP
Button. My data comes back as if I had never cleared it. It seems to
remember when it reposts. (I just called ViewState.clear ). Will the
method below work to restore a blank slate page (pre-databind)...I wish
they had a data.unbind!!!

By the way, I have found that if I redirect myself back I have no
problem, but this seems kludgy...

Thanks,
Ryan

Chris Botha wrote:
Do you want to reset the form and post back?
In this case change the type of the button to "button" instead of "reset".
Then in HTML view of the page, do the following:
Add an onclick event for the Java Script, so it should look something like
this
<INPUT onclick="DoTheR eset();" id="Reset1" ......
Note the semi-colon after the function name, because it is runat server, MS
will add more Java script for postback, else you will get an error.
Then add Java script right to the end of the page
function DoTheReset() {
Form1.reset();
}

Your script will run first, then the MS script to do the postback.
"Ryan" <ry************ @kp.org> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello,

I have a standard HTML button on an aspx web form that I have set to
runat server. The button is named reset1 and its tag is as follows:

<INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset"
value="Reset" name="btnReset1 " runat="server">

Using Interdev I then double click the button in design view and in the
code behind page (aspx.vb) have the following:

Private Sub btnReset1_Serve rClick(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles btnReset1.Serve rClick
Response.Write( "<SCRIPT LANGUAGE='javas cript'>")
Response.Write( "alert('hi' )")
Response.Write( "</SCRIPT>")
End Sub

All my <ASP:OBJECTS> run fine, but NOTHING happens when I click this
one button. I have tried adding different onclick events to call the
code behind without success. What do I need to do to get this button
to fire the server-side code?

Thanks,
Ryan


Nov 19 '05 #4
Redirect back to the page is a good idea then, it is simple and if it works
for you it is less kludgy than Java script, etc.
"Ryan" <ry************ @kp.org> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Hi Chris,

Yes, this is what I am looking to do. The problem with the different
approaches I have tried so far is that I am trying to get to a
completely clean page...pre-databinding. I have tried clearing the all
the fields using javascript then clearing the view state using an ASP
Button. My data comes back as if I had never cleared it. It seems to
remember when it reposts. (I just called ViewState.clear ). Will the
method below work to restore a blank slate page (pre-databind)...I wish
they had a data.unbind!!!

By the way, I have found that if I redirect myself back I have no
problem, but this seems kludgy...

Thanks,
Ryan

Chris Botha wrote:
Do you want to reset the form and post back?
In this case change the type of the button to "button" instead of
"reset".
Then in HTML view of the page, do the following:
Add an onclick event for the Java Script, so it should look something
like
this
<INPUT onclick="DoTheR eset();" id="Reset1" ......
Note the semi-colon after the function name, because it is runat server,
MS
will add more Java script for postback, else you will get an error.
Then add Java script right to the end of the page
function DoTheReset() {
Form1.reset();
}

Your script will run first, then the MS script to do the postback.
"Ryan" <ry************ @kp.org> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
> Hello,
>
> I have a standard HTML button on an aspx web form that I have set to
> runat server. The button is named reset1 and its tag is as follows:
>
> <INPUT id="btnReset1" style="WIDTH: 60px; HEIGHT: 24px" type="reset"
> value="Reset" name="btnReset1 " runat="server">
>
> Using Interdev I then double click the button in design view and in the
> code behind page (aspx.vb) have the following:
>
> Private Sub btnReset1_Serve rClick(ByVal sender As System.Object, ByVal
> e As System.EventArg s) Handles btnReset1.Serve rClick
> Response.Write( "<SCRIPT LANGUAGE='javas cript'>")
> Response.Write( "alert('hi' )")
> Response.Write( "</SCRIPT>")
> End Sub
>
> All my <ASP:OBJECTS> run fine, but NOTHING happens when I click this
> one button. I have tried adding different onclick events to call the
> code behind without success. What do I need to do to get this button
> to fire the server-side code?
>
> Thanks,
> Ryan
>

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1430
by: Libra Blue | last post by:
I try to set the page title dynamically in an aspx page, but sometimes an error occurs due to VS removing the runat="server" attribute at its own will... How do I stop from doing so?? Libra Blue
2
294
by: Lubomir | last post by:
Hi, I have a BoundColumn in a DataGrid: <asp:BoundColumn DataField="lastname" SortExpression="lastname" ReadOnly="True" HeaderText="Last Name"></asp:BoundColumn> Column is sorted. I am wondering why this code is working properly as there is missing the statement runat="server".
2
6166
by: Miguel Dias Moura | last post by:
Hello, I have this line: <div runat="server" id="category-header"> I get this error: 'category-header' is not a valid identifier. When I use: <div runat="server" id="category-header">
6
2708
by: Martin Eyles | last post by:
Hi, I have a page that contains the following <div runat="server" id="Pikea"> <object runat="server" id="PiTV" style="width:560px; height:560px" classid="clsid:{3DF152A5-521D-4330-A8DC-1424CEB66BAA}" VIEWASTEXT> </object> </div>
3
5514
by: Jaime Stuardo | last post by:
Hi all... Both controls are server side. The former has more properties. Both may have associated events that are ran at server. Which one are recommended to use? is performance an issue? in what case I can (or must) use the second? If I want an input control that has specific font or color, I can use client side <input> so I'm...
0
982
by: uto | last post by:
<uc1:uc_pager ID="Uc_pager1" runat="server" CurrentPage="<%=page%>" PageCount="<%=pageCount%>" PageSize="<%=pageSize%>" /> i'd like to input data into usercontrol when page loading but this <%= %> tag does't work how can i change this tage to work it?
4
2895
by: Kevin Blount | last post by:
bit long winded this one, so stick with me: I'm trying to create a form that can go to one of 3 places, depending on various elements. My form control looks like this: <form runat="server" ID="myForm" method=POST> so, first thing: how can I dynamically set the "Action" parameter? I know that with <asp:HiddenField...for example, I have...
4
13293
by: Chris | last post by:
Hi, i 'm experimenting with postback and i tried that with a button server control and an Html input button but with runat="server". The button server control causes a postback, but not the Html input button with runat="server". Can someone explain me why (because it's running on the server)? Thanks
19
11229
by: Scott M. | last post by:
Why do we need runat="server" on our <headtags?
0
7918
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8206
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5713
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.