472,785 Members | 1,152 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,785 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 8296
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.