I want to know what is the purpose of runat="server" attribute??
For example, for a submit button, it just submit the form data to the
server, whats the differences between
<input type="submit" name="submit1">
<input type="submit" name="submit1" runat="server">
Please advise! Thanks!! 5 2078
Hi,
from what I have seen, runat="server" allows you programmatically use HTML
controls on the server side, plus to keep their values in ViewState. This is
quiet neat, since they are lightweight and do the job. The only thing I
found inconvinient is that ListBox, for instance, doesn't save the
SelectedIndex value on it's way back to server (PostBack).
--
With the best wishes,
Shaul Feldman
"Matt" <ma*******@hotmail.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl... I want to know what is the purpose of runat="server" attribute??
For example, for a submit button, it just submit the form data to the server, whats the differences between
<input type="submit" name="submit1"> <input type="submit" name="submit1" runat="server">
Please advise! Thanks!!
Matt wrote: I want to know what is the purpose of runat="server" attribute??
For example, for a submit button, it just submit the form data to the server, whats the differences between
<input type="submit" name="submit1"> <input type="submit" name="submit1" runat="server">
Please advise! Thanks!!
In the case of the submit button, the runat="server" attribute will
be rarely necessary.
But you need it if, for instance, you want to change the value
(the text on the button) from code:
If(Adding) Then
submit1.Value = "Add"
Else
submit1.Value = "Update"
End If
--
Jos
I agree. ViewState is the deal. As far as List Boxes are concerned, you can always explicitly save the selected value in ViewState. Just one line of code in a "SelectedIndexChanged" event. Easy enough to do
Actually, by using runat="server" your making the "HTML Control" a "Web Control" which is, in effect an object that is easily manipulated on the server and which renders HTML just before the page is sent to the browser. In addition to ViewState, Web Controls give you an event model for handling things like changes in values, selected items, submitted buttons, etc
You'll see a lot of other benefits as you get into designing your own controls, nesting controls within other controls - it's a whole new world
It also means that you can write an event procedure for it. Something like this..
Private Sub submit1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit1.ServerClic
....do your thing here..
End Su
So, if there's several buttons, you can deal with each one differently
Try it - that won't work without runat="server"
Hi,
I agree with you on "SelectedIndexChanged" event, the problem is that it
makes an extra PostBack. Sometimes I preffer to stay at client and not to
postback at all. My solution was to send the SelectedIndex as a parameter
when the main postback (from my application's point of view) was commited.
--
With the best wishes,
Shaul Feldman
"Rich" <an*******@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com... I agree. ViewState is the deal. As far as List Boxes are concerned, you
can always explicitly save the selected value in ViewState. Just one line
of code in a "SelectedIndexChanged" event. Easy enough to do. Actually, by using runat="server" your making the "HTML Control" a "Web
Control" which is, in effect an object that is easily manipulated on the
server and which renders HTML just before the page is sent to the browser.
In addition to ViewState, Web Controls give you an event model for handling
things like changes in values, selected items, submitted buttons, etc. You'll see a lot of other benefits as you get into designing your own
controls, nesting controls within other controls - it's a whole new world. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hazzard |
last post by:
I just realized that the code I inherited is using all asp.net server
controls (ie. webform controls) and when I try to update textboxes on the
client side, I lose the new value of the textbox when...
|
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
|
by: Matt |
last post by:
If the web control has runat="server" attribute, can we say that control is
built on the server (on the fly), and not static control??
Please advise.
|
by: COHENMARVIN |
last post by:
I'm a asp programmer starting out with asp.net. I understand that an
asp form can post to its own page and that this allows validation of
form fields on the server. But suppose all the controls...
|
by: Ryan |
last post by:
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;...
|
by: gunjan.mait |
last post by:
hi,
i wanted to know the exact use of runat="server" which is being used
is ASP.NET
why we every time need to use it, even when i want to do the work at
client side? How to do simple processings...
|
by: mark4asp |
last post by:
<form runat="server"automatically adds <divtag to code contained
within. Is there a way to stop that?
Mixing block-level elements with inline-level elements messes up the
HTML becasuse that is...
|
by: Bob |
last post by:
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...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |