473,395 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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_ServerClick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnReset1.ServerClick
Response.Write("<SCRIPT LANGUAGE='javascript'>")
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 6434
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="DoTheReset();" 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.googlegr oups.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_ServerClick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnReset1.ServerClick
Response.Write("<SCRIPT LANGUAGE='javascript'>")
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="DoTheReset();" 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.googlegr oups.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_ServerClick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnReset1.ServerClick
Response.Write("<SCRIPT LANGUAGE='javascript'>")
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="DoTheReset();" 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.googlegr oups.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_ServerClick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnReset1.ServerClick
Response.Write("<SCRIPT LANGUAGE='javascript'>")
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.googlegr oups.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="DoTheReset();" 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.googlegr oups.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_ServerClick(ByVal sender As System.Object, ByVal
> e As System.EventArgs) Handles btnReset1.ServerClick
> Response.Write("<SCRIPT LANGUAGE='javascript'>")
> 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
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
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...
2
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
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"...
3
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...
0
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...
4
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"...
4
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...
19
by: Scott M. | last post by:
Why do we need runat="server" on our <headtags?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.