473,385 Members | 1,356 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,385 software developers and data experts.

runat="server"....a simple html textbox or a webform server textbox...that is the question.

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 submitting the form to
update the database. The server doesn't have the client side value any more.

It seems to me that as I begin to write the client side javacript code for
form validation and client side editing capabilities in order to save round
trips to the server, I should change all these "data entry" controls, at
least the humble textbox...to a simple html control.

Can I just simply remove the ' runat="server" ' statement at the beginning
of the textbox control along with removing the asp: from the <asp:textbox
statement ?

Do I want to do this? I know I can answer my own question partially by
saying that I want to initially populate my textbox from the server side
when I initially load my page with database values. After that however, I
would like to not be bound by the server for this control in that state that
Kevin Spencer so correctly once referred to as that point at which "The
server and client are irreparably separated" I hope I didn't take that out
of context for Kevin.

I know I have used Request.Form in the past to pass along values to the
server but that seems to get me back into that round trip way of doing
business. I can see the value of passing a value back to the server if it is
used for a test condition, the result being used to generate an altered
client page, but it seems that in general for just changing the value of say
"company name" or "address", then just hanging an html textbox out there is
all I want for this.

It sounds like my question is when to use the straight html textbox and when
to use the server control textbox. And I am willing to admit that I should
know the answer to that question but I honestly flat out do not.

Thanks for your advice, explanations, or opinions.

Greg Hazzard
Nov 17 '05 #1
2 8362
Hi,

if you set the control value in the page load and don’t protect against
re-assignment while post back happened the value will be restore to the
one set in the page_load any way. If you don’t set any value to the
control it will hold data if entered by user or by javascript. I add a
sample code[1].

For your question, when I start using (checking) ASP.NET I use the
server controls as much as I can. I was fascinated from the web controls
event model. But as the time moves on and I start to test application
for performance and network pressure I found out that there are "SOME"
problems with web controls. The model event force post back to the
client. To simulate a single page filling add the annoying view state
that hurt network connection with low bandwidth. Now days I try to use
HTML control as much as I can. if I create page without any post back
events (like date selection modal form, or any modal form that return
value to the calling page) I’m not using web controls.

[1] -
Code behind:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

}
private void Button1_Click(object sender, System.EventArgs e)
{
String s = this.TextBox1.Text;
}

HTML :
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script id="clientEventHandlersJS" language="javascript">
<!--

function nat_onclick() {
document.all["TextBox1"].value = "natty";
}

//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="WebForm3" method="post" runat="server">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 205px;
POSITION: absolute; TOP: 103px" runat="server" Width="146px"
Height="63px"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 187px; POSITION:
absolute; TOP: 200px" runat="server" Width="36px" Height="21px"
Text="Button"></asp:Button>
<INPUT id="nat" name="nat" style="Z-INDEX: 103; LEFT: 402px; WIDTH:
62px; POSITION: absolute; TOP: 112px; HEIGHT: 19px" type="button"
value="Button" language="javascript" onclick="return nat_onclick()">
</form>
</body>
</HTML>

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
Hi Greg,

I am glad to hear it. Please post here if there are any more questions. Thanks very much for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Hazzard" <ha**@sonic.net>
!References: <Ow**************@tk2msftngp13.phx.gbl> <uM**************@TK2MSFTNGP12.phx.gbl>
<OX**************@tk2msftngp13.phx.gbl> <Nz**************@cpmsftngxa06.phx.gbl>
!Subject: Re: runat="server"....a simple html textbox or a webform server textbox...that is the question.
!Date: Mon, 21 Jul 2003 20:27:40 -0700
!Lines: 305
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <OC**************@TK2MSFTNGP11.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: dial-209-148-114-18.sonic.net 209.148.114.18
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:160887
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Thank you YanHong.
!I actually found out I left out a test for Ispostback and my code was taking
!an unintended path. My database edit functionality is working great now
!using the Microsoft Data Access Application Block.
!I still have some Javascript validation to carve into the presentation layer
!but using asp.net with FrontPage 2003, I have an application that I really
!like the looks of right now. The FrontPage html that is generated is clean
!and the themes are easily integrated with asp.net. I am not really going to
!worry about the resources used by the controls coming out of the
!System.Web.UI.WebControl namespace.
!
!With a PocketPC proof of concept yet to do, a web service to develop, some
!kind of XML Cursor API to demo....I am not too worried about a few extra
!calories at this point.
!
!All the best,
!Greg Hazzard
!Sebastopol, CA
!
!
!
!"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message
!news:Nz**************@cpmsftngxa06.phx.gbl...
!> Hello Greg,
!>
!> By the way, if you create HtmlControls dynamically in the codebehind they
!will still have to be processed on the server to
!> create the Html. In fact even if they are in the aspx page they still
!have a small amount of overhead since the server still
!> creates an object for each Html element with a runat=server property. You
!are right that WebControls do use far more
!> resources though.
!>
!> Here are the naming conventions we use for the .NET Framework
!documentation:
!>
!>
!>
!>
!> Control
!>
!> Description
!>
!>
!> ASP+ server control
!>
!> Do not use. Use Web server control.
!>
!> Note If referring to the superset of server controls, use ASP.NET server
!control.
!>
!>
!> ASP.NET server control
!>
!>
!>
!> A control on an ASP.NET page. An ASP.NET server control has a runat=server
!attribute on a page. ASP.NET server
!> controls comprise a superset that includes Web server controls, HTML
!server controls, mobile controls, and so on.
!>
!>
!> custom control
!>
!>
!>
!> A control authored by a user or a third-party software vendor that does
!not belong to the .NET Framework class library. The
!> term custom control is a generic term. For specific contexts, use the
!following qualifiers:
!>
!> custom server control: a control used with ASP.NET pages.
!>
!> custom client control: a control used with Windows Forms.
!>
!>
!> HTML control
!>
!> Do not use. Use HTML server control.
!>
!>
!> HTML server control
!>
!> A control that appears as an HTML element marked by a runat=server
!attribute on an ASP.NET page. In contrast to Web
!> server controls, HTML server controls do not have an <asp:xxx> tag prefix.
!An HTML server control belongs to the
!> System.Web.UI.HtmlControls namespace.
!>
!>
!> server control
!>
!> Abbreviated form of ASP.NET server control. Use ASP.NET server control in
!the first mention in a topic and server control
!> thereafter.
!>
!>
!> server HTML control
!>
!> Do not use. Use HTML server control.
!>
!>
!> user control
!>
!> In ASP.NET: A user-authored server control that is developed as an ASP.NET
!page and saved as a text file with an .ascx
!> extension. The ASP.NET page framework compiles a user control on the fly
!to a class that derives from
!> System.Web.UI.UserControl.
!>
!> In Windows Forms: A user-authored client-side control that is developed by
!combining existing controls. A Windows Forms
!> user control is a class that derives from System.WinForms.UserControl.
!>
!>
!> Web control
!>
!> Do not use. If referring to a control that belongs to the
!System.Web.UI.WebControls namespace, use Web server control.
!> Otherwise use ASP.NET server control.
!>
!>
!> Web Forms control
!>
!> Do not use. If referring to the superset of server controls, use ASP.NET
!server control. Otherwise use a specific category
!> such as Web server control or HTML server control.
!>
!>
!> Web server control
!>
!> A control that has an <asp:xxxx> prefix on an ASP.NET page. A Web server
!control belongs to the
!> System.Web.UI.WebControls namespace.
!>
!> Hope it helps.
!>
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!>
!> Get Secure! - www.microsoft.com/security
!> This posting is provided "AS IS" with no warranties, and confers no
!rights.
!>
!> --------------------
!> !From: "Hazzard" <ha**@sonic.net>
!> !References: <Ow**************@tk2msftngp13.phx.gbl>
!<uM**************@TK2MSFTNGP12.phx.gbl>
!> !Subject: Re: runat="server"....a simple html textbox or a webform server
!textbox...that is the question.
!> !Date: Sun, 20 Jul 2003 05:19:14 -0700
!> !Lines: 124
!> !X-Priority: 3
!> !X-MSMail-Priority: Normal
!> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !Message-ID: <OX**************@tk2msftngp13.phx.gbl>
!> !Newsgroups: microsoft.public.dotnet.framework.aspnet
!> !NNTP-Posting-Host: dial-209-148-114-239.sonic.net 209.148.114.239
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl
!microsoft.public.dotnet.framework.aspnet:160564
!> !X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!> !
!> !Thank you once again Natty. It just occurred to me that I do have mentors
!in
!> !software development. Felix Wu has also been very helpful and so many
!> !others.
!> !
!> !I ran the code you supplied. Good basic exercise. I am digesting this. I
!> !think it demonstrates well the difference between client side button
!> !invocations and a server side round trip.
!> !
!> !You mentioned the view state. I was working on a project where a Sybase
!> !solution used something called an HTMLDatawindow. It also used a
!mechanism
!> !that I think is similar to the viewstate. I am still learning here so I
!want
!> !to reserve my own judgement but one thing the HTMLDatawindow did that I
!am
!> !glad the ASP.NET doesn't do is add a bunch of additional overhead for
!client
!> !side validation, etc. Without trying to explain further, a basic
!> !HTMLDatawindow page that was sent to the client weighed in with at least
!> !100K of code as I recall. Some very basic pages served up 300K. On 56K
!dial
!> !up modem connections this app was as slower than cold honey. Without
!> !wanting to try to carry this comparison or explanation any further, the
!> !point is that overhead with any system can clog the bandwidth. And then
!> !there is the complication factor.
!> !
!> !I think the value of your reply Natty is that I am seeing the value in
!> !trying to keep my solution as 'clean' as possible without loading it up
!with
!> !controls I don't need and in some cases I don't want. If I don't
!understand
!> !them, that is even worse.
!> !
!> !At least the issue of web controls and viewstate is an order of magnitude
!> !easier to deal with than the Design Time Controls (DTC's) that existed in
!> !Visual Interdev. Those were, as the particular Sybase technology I
!> !mentioned, 'controls on steroids'. They looked good in the beginning but
!had
!> !serious side effects.
!> !
!> !Appreciatively,
!> !
!> !Greg Hazzard
!> !Sebastopol CA
!> !
!> !
!> !
!> !
!> !"Natty Gur" <na***@dao2com.com> wrote in message
!> !news:uM**************@TK2MSFTNGP12.phx.gbl...
!> !> Hi,
!> !>
!> !> if you set the control value in the page load and don't protect against
!> !> re-assignment while post back happened the value will be restore to the
!> !> one set in the page_load any way. If you don't set any value to the
!> !> control it will hold data if entered by user or by javascript. I add a
!> !> sample code[1].
!> !>
!> !> For your question, when I start using (checking) ASP.NET I use the
!> !> server controls as much as I can. I was fascinated from the web
!controls
!> !> event model. But as the time moves on and I start to test application
!> !> for performance and network pressure I found out that there are "SOME"
!> !> problems with web controls. The model event force post back to the
!> !> client. To simulate a single page filling add the annoying view state
!> !> that hurt network connection with low bandwidth. Now days I try to use
!> !> HTML control as much as I can. if I create page without any post back
!> !> events (like date selection modal form, or any modal form that return
!> !> value to the calling page) I'm not using web controls.
!> !>
!> !> [1] -
!> !> Code behind:
!> !> private void Page_Load(object sender, System.EventArgs e)
!> !> {
!> !> // Put user code to initialize the page here
!> !>
!> !> }
!> !> private void Button1_Click(object sender, System.EventArgs e)
!> !> {
!> !> String s = this.TextBox1.Text;
!> !> }
!> !>
!> !> HTML :
!> !> <HTML>
!> !> <HEAD>
!> !> <title>WebForm3</title>
!> !> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
!> !> <meta name="CODE_LANGUAGE" Content="C#">
!> !> <meta name="vs_defaultClientScript" content="JavaScript">
!> !> <meta name="vs_targetSchema"
!> !> content="http://schemas.microsoft.com/intellisense/ie5">
!> !> <script id="clientEventHandlersJS" language="javascript">
!> !> <!--
!> !>
!> !> function nat_onclick() {
!> !> document.all["TextBox1"].value = "natty";
!> !> }
!> !>
!> !> //-->
!> !> </script>
!> !> </HEAD>
!> !> <body MS_POSITIONING="GridLayout">
!> !> <form id="WebForm3" method="post" runat="server">
!> !> <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 205px;
!> !> POSITION: absolute; TOP: 103px" runat="server" Width="146px"
!> !> Height="63px"></asp:TextBox>
!> !> <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 187px; POSITION:
!> !> absolute; TOP: 200px" runat="server" Width="36px" Height="21px"
!> !> Text="Button"></asp:Button>
!> !> <INPUT id="nat" name="nat" style="Z-INDEX: 103; LEFT: 402px; WIDTH:
!> !> 62px; POSITION: absolute; TOP: 112px; HEIGHT: 19px" type="button"
!> !> value="Button" language="javascript" onclick="return nat_onclick()">
!> !> </form>
!> !> </body>
!> !> </HTML>
!> !>
!> !> Natty Gur, CTO
!> !> Dao2Com Ltd.
!> !> 28th Baruch Hirsch st. Bnei-Brak
!> !> Israel , 51114
!> !>
!> !> Phone Numbers:
!> !> Office: +972-(0)3-5786668
!> !> Fax: +972-(0)3-5703475
!> !> Mobile: +972-(0)58-888377
!> !>
!> !> Know the overall picture
!> !>
!> !>
!> !> *** Sent via Developersdex http://www.developersdex.com ***
!> !> Don't just participate in USENET...get rewarded for it!
!> !
!> !
!> !
!>
!>
!
!
!
Nov 17 '05 #3

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
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...
4
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;...
3
by: Jim in Arizona | last post by:
Most of the asp.net learning I've done has been from books that were written during the 1.0 framework. I didn't have a copy of visual studio when I started reading them then I got a hold of VS 2005...
3
by: Jeff | last post by:
hey asp.net 2.0 If I have a plain html table in my asp.net 2.0 webpage, and later decide to add this property: runat="server" to the table. Does this turn the table into a asp.net table...
11
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...
2
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...
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...
3
by: raghulvarma | last post by:
if I type the code as <input type="text" name="txtbox" > and make the script language as function empty() { if(document.Form1.txtbox.value=="") { alert("should not be...
1
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
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...
0
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$) { } ...
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?
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...

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.