473,722 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8400
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(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here

}
private void Button1_Click(o bject sender, System.EventArg s e)
{
String s = this.TextBox1.T ext;
}

HTML :
<HTML>
<HEAD>
<title>WebForm3 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio 7.0">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script id="clientEvent HandlersJS" language="javas cript">
<!--

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="javas cript" 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.publi c.dotnet.framew ork.aspnet
!NNTP-Posting-Host: dial-209-148-114-18.sonic.net 209.148.114.18
!Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
!Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1608 87
!X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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******* *******@cpmsftn gxa06.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.H tmlControls 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.U serControl.
!>
!> 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.W ebControls 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*********** ***@TK2MSFTNGP1 2.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.publi c.dotnet.framew ork.aspnet
!> !NNTP-Posting-Host: dial-209-148-114-239.sonic.net 209.148.114.239
!> !Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
!> !Xref: cpmsftngxa06.ph x.gbl
!microsoft.publ ic.dotnet.frame work.aspnet:160 564
!> !X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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******* *******@TK2MSFT NGP12.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(objec t sender, System.EventArg s e)
!> !> {
!> !> // Put user code to initialize the page here
!> !>
!> !> }
!> !> private void Button1_Click(o bject sender, System.EventArg s e)
!> !> {
!> !> String s = this.TextBox1.T ext;
!> !> }
!> !>
!> !> HTML :
!> !> <HTML>
!> !> <HEAD>
!> !> <title>WebForm3 </title>
!> !> <meta name="GENERATOR " Content="Micros oft Visual Studio 7.0">
!> !> <meta name="CODE_LANG UAGE" Content="C#">
!> !> <meta name="vs_defaul tClientScript" content="JavaSc ript">
!> !> <meta name="vs_target Schema"
!> !> content="http://schemas.microso ft.com/intellisense/ie5">
!> !> <script id="clientEvent HandlersJS" language="javas cript">
!> !> <!--
!> !>
!> !> 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="javas cript" 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
1442
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
5537
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 what case I can (or must) use the second? If I want an input control that has specific font or color, I can use client side <input> so I'm wondering if there is an advantage to use <input> as
4
6528
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; 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:
3
3493
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 Beta 1, then Beta 2. I was using the <div runat="server"> statement on my projects. Once I placed a <div id="testdiv" runat="server"> within my aspx page, I could then manipulate it in the code behind like so: testdiv.visible = true...
3
5594
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 (<asp:Table ID="Table1" runat="server">)??? Jeff
11
2562
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 like displaying some message at client side only without hitting server? what is the use of onclick, as we have to use onserverclick always? why it is not possible to do the things without using runat="server" in script?
2
2324
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 "klik()" ). I want to do a 'server onclick', just like the <asp:Buttoncontrol, but it
4
13306
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 Html input button with runat="server". Can someone explain me why (because it's running on the server)? Thanks
3
1707
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 blank"); return false; }
0
8739
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.