473,399 Members | 3,401 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,399 software developers and data experts.

Form controls and code behind

Hi,

Suppose I have an form that contains any number of controls. To access
these controls programatically and get/set the state of their
properties, must they all be server controls (have the runat="server"
attribute)?

Thanks,
Roshawn
Nov 19 '05 #1
3 1158
Roshawn,

If you mean server-side access, then yes. You can always access any controls
on client side.

Eliyahu

"Roshawn Dawson" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,

Suppose I have an form that contains any number of controls. To access
these controls programatically and get/set the state of their
properties, must they all be server controls (have the runat="server"
attribute)?

Thanks,
Roshawn

Nov 19 '05 #2
As long as the control is marked as runat="server" and has an ID it
should be accessible in the code behind as long as you define it inside
the main class.

Nov 19 '05 #3
This applies to the HTML controls in the HTML tab of your VS.NET toolbox:
If you want to access the controls from your server side code then yes, they
will need the runat="server" attribute.
If you don't need to interact with the controls at all, or if you only want
to interact with the controls with client side script, then you don't need
the runat="server" attribute on the control and it's best for performance
reasons to leave it off.

Here's more info:
http://SteveOrr.net/faq/3in1.aspx#ServerControl

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Roshawn Dawson" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,

Suppose I have an form that contains any number of controls. To access
these controls programatically and get/set the state of their properties,
must they all be server controls (have the runat="server" attribute)?

Thanks,
Roshawn

Nov 19 '05 #4

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

Similar topics

15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
2
by: av | last post by:
hi,I have couple of Questions regarding the ASP.NET. Post the Values from WebPage1.aspx to WebPage2.aspx The code i have is in webpage1.aspx <form action="webpage2.aspx" method=post...
11
by: Tom | last post by:
Hi all, I posted the same question one week ago in http://communities.microsoft.com/newsgroups/previewFrame.as p? ICP=msdn&sLCID=us&sgroupURL=microsoft.public.dotnet.framewo...
1
by: john | last post by:
We have an asp.net page that we are mixing our C# code on both the code behind and in the .aspx page. We are using the code behind for a server side control that has post back events. but we are...
4
by: David | last post by:
I have trying to have a webform inherit controls from another form and can't get it to work Say I have a form that saves the person's demographic info. ****one.aspx**** //I have an object...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
10
by: Mr Newbie | last post by:
DropDown lists and Listboxes do not appear in the list of controls and values passed back to the server on PostBack in Request.Form object. Can someone confirm this to be correct and possibly...
4
by: mrmagoo | last post by:
If I create a form and add add a bunch of controls and code, etc to it, I can see that Visual Studio adds all of the requisite "creation" code behind the form. If I wanted to create a 2nd copy...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
1
by: mirandacascade | last post by:
1) Module1 has the following delcaration: Public g_frmZZZ as Form Public g_txtForm2 as Variant 2) app has two forms: form1 and form2 3) a command button on form1 opens form2; it also has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
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...
0
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...
0
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...

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.