473,395 Members | 1,440 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.

Do all ASP buttons do submit?

I'm looking at this web page:
http://www.allasp.net/enterkey.aspx

Where they say:

Remember:

* <asp:Button> controls render as <input type=submit value=xxx> html elements.
* <asp:HtmlInputButton> controls render as <input type=button value=xxx
onclick=__doPostBack(...)> html elements.
* <asp:HtmlButton> controls render as <button onclick=__doPostBack(...)>xxx</button>

Okay, the first case does a submit. The other two cases do the __doPostBack() calls
which presumably also do submits. The main difference between the Button on one hand
and tht HtmlInputButton and HtmlButton on the other hand is that the latter two will
cause IsPostBack to test as true in the CodeBehind. But they all cause a submit, right?

Suppose one wants to have a button that does not cause a submit of the current page
and that instead goes an HTML GET to another URL. Is there a way to do that with some
asp: button control?

What I want to do: have rows in a DataGrid with buttons to click to various other
pages. I guess I could do that via a CodeBehind redirect. But why go thru that
overhead on the server? Doesn't that redirect require an additional handshake between
the browser and server where the server has to tell the browser to do an HTML GET?

So how to describe that buttons in a grid column should go to links without submit
happening?
Nov 19 '05 #1
5 2630

Randall Parker wrote:
I'm looking at this web page:
http://www.allasp.net/enterkey.aspx

Where they say:

Remember:

* <asp:Button> controls render as <input type=submit value=xxx> html elements.
* <asp:HtmlInputButton> controls render as <input type=button value=xxx
onclick=__doPostBack(...)> html elements.
* <asp:HtmlButton> controls render as <button onclick=__doPostBack(...)>xxx</button>

Okay, the first case does a submit. The other two cases do the __doPostBack() calls
which presumably also do submits. The main difference between the Button on one hand
and tht HtmlInputButton and HtmlButton on the other hand is that the latter two will
cause IsPostBack to test as true in the CodeBehind. But they all cause a submit, right?


They all do exactly the same thing. All will post back unless you tell
them not to. All will trip the IsPostBack flag. All can have events
hooked up to them. The only reason that <asp:Button> and its friends
exist at all is the vain hope that maybe you'll forget what an actual
HTML tag looks like and be forced to continue using ASP.NET forever.

The fact that you bothered to read up on the issue shows that you're
not one to drink the Microsoft Cool Aid without first learning what's
in it. For you, I'd recommend <input type=submit runat=server>.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Nov 19 '05 #2
How do you tell them not to post back? Is there some attribute in a flag?

I'm looking at the members of HtmlInputButton and so not see a property that looks
like it suppresses postback. Is there one?

Also, you refer to:
<input type=submit runat=server>

Why would one put runat=server on a tag that will become an HTML page tag? The input
tag is not asp:input. It is just plain input. I thought runat=server was only used
for tags that you want the ASP.Net pre-processor to translate into something else.

Though I'm an ASP.Net novice and I still do not understand some basics. So maybe I'm
wrong.

Jason Kester wrote:

They all do exactly the same thing. All will post back unless you tell
them not to. All will trip the IsPostBack flag. All can have events
hooked up to them. The only reason that <asp:Button> and its friends
exist at all is the vain hope that maybe you'll forget what an actual
HTML tag looks like and be forced to continue using ASP.NET forever.

The fact that you bothered to read up on the issue shows that you're
not one to drink the Microsoft Cool Aid without first learning what's
in it. For you, I'd recommend <input type=submit runat=server>.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Nov 19 '05 #3
Randall Parker wrote:
How do you tell them not to post back? Is there some attribute in a flag?
That's just HTML:
<input type="button" onclick="myClientSideFunction()">
Also, you refer to:
<input type=submit runat=server>

Why would one put runat=server on a tag that will become an HTML page tag? The input
tag is not asp:input. It is just plain input. I thought runat=server was only used
for tags that you want the ASP.Net pre-processor to translate into something else.
No. runat=server is available for any HTML tag. <br id="myBR"
runat=server/> is perfectly valid, and will be available to you as a
HtmlGenericControl on the server.

Take a look at the HTML generated by <asp:button> for an answer to your
question. It will render as <input type=submit>, plus a bunch of
script. The question you will eventually want to ask youself is, since
it's rendering as an INPUT anyway, why not declare it as one?

Though I'm an ASP.Net novice and I still do not understand some basics. So maybe I'm
wrong.
Try to learn a bit about HTML and CGI programming outside of the
context of ASP.NET. Seriously, install Perl or PHP on a server and
write some simple database tools. It will take away a lot of
misconceptions about the things that ASP.NET is doing for you behind
the scenes.
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/



Nov 19 '05 #4
Jason,

I think I finally understand: So you are saying that HtmlGenericControl is a class on
the server-side that does not match the name of an ASP.Net tag? You just assign
runat=server to a normal HTML tag and then you can access that tag in CodeBehind by
declaring a variable with the same name as its ID?

Yes, if one can do that then some of the ASP.Net tags become a lot less necessary.
Plus, one gets more control over what gets produced.

Jason Kester wrote:
No. runat=server is available for any HTML tag. <br id="myBR"
runat=server/> is perfectly valid, and will be available to you as a
HtmlGenericControl on the server.

Take a look at the HTML generated by <asp:button> for an answer to your
question. It will render as <input type=submit>, plus a bunch of
script. The question you will eventually want to ask youself is, since
it's rendering as an INPUT anyway, why not declare it as one?

Nov 19 '05 #5
Exactly. Most tags that you'll actually want to touch from the server
will have their own HtmlControl equivilant (HtmlAnchor, HtmlInputText,
HtmlTableRow, etc.) The rest can still be dealt with as
HtmlContainerControl or HtmlGenericControl objects.

The only <asp:...> tags that I use on a regular basis are the helpers
such as Repeater and DataGrid, and the occasional Literal. There are
certain specific (and very rare) cases where <asp:button> is more
useful than <input type="button" runat=server>, but for the most part I
prefer my Html to look like Html.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/

Nov 19 '05 #6

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

Similar topics

3
by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data">...
4
by: Bob Lehmann | last post by:
Hi, I pretty sure I've seen this problem addressed before, but I can't find any references. The short story is that I have I have multiple submit buttons on a page, each providing different...
2
by: Matt | last post by:
The ASP page has multiple buttons, and when the user clicks different buttons, it will submit the form data to different URLs. My first approach was to use BUTTON type, and triggers javascript...
1
by: sman | last post by:
Hi, I recently read this article on About.com on how to create required fields for a form: http://javascript.about.com/library/scripts/blformvalidate.htm Everything works great except that there...
9
by: Poker Man | last post by:
Hi, I know how to do Sumbit buttons in Forms, and I know how to do custom buttons in Javascript. What I can't seem to find is how to do custom Submit buttons using Javascript! Anybody out...
1
by: Bill_W_Stephens | last post by:
I have a complicated page with several submit buttons. I don't want to create multiple forms because much of the input is shared and the code is getting very ugly. However I would like to determine...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
2
by: rudranee | last post by:
hello, How do i declare multiple submit buttons on a form? and how do i come to know on the next page which button has been clicked? Can i do it in JSP page? Please tell me.
5
by: Steve JORDI | last post by:
Just a question using images as submit buttons and PHP4.4.4. It seems that my code correctly works in FireFox but not in IExplorer. For example, I have a FORM with 2 buttons called "search" and...
3
by: brian210 | last post by:
I am currently trying to make a four question quiz. Each question is on a new page. There will be a previous button and a next button to take the user to the previous and next question respectively....
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...

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.