473,385 Members | 1,888 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.

How to access the Form from the code behind? VB.NET

I have a form declared like this in the html

<form id="SearchResults" method="post" runat="server" name="frmMain"></form>

I don't see the form anywhere in the codebehind and I am not able to access
it like this
Me.frmMain or Me.SearchResults.
Is it not possible to access the form from the code behind or am I missing
something?

Thanks
Nov 19 '05 #1
4 2882
System.Web.UI.Page inherits System.Web.UI.Control, so you can identify any
Control in its immediate hierarchy via the Control.FindControl() method. To
access the Form, and it's child Controls, you would use
Page.FindControl("SearchResults") which returns the Form Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Chris Lane" <Ch*******@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
I have a form declared like this in the html

<form id="SearchResults" method="post" runat="server"
name="frmMain"></form>

I don't see the form anywhere in the codebehind and I am not able to
access
it like this
Me.frmMain or Me.SearchResults.
Is it not possible to access the form from the code behind or am I missing
something?

Thanks

Nov 19 '05 #2
Thanks

Is there any reason why it doesn't get declared in the codebehind when you
add the runat=server property value?

What I want to do is add an attribute the form.

Thank You for your help it is much appreciated.
Nov 19 '05 #3
As the Form is a Control in the page, you can modify it the same way that
you would modify any other Control in the Page. Create a reference to it
using Page.FindControl as I mentioned, and then have your way with it! ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"Chris Lane" <Ch*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
Thanks

Is there any reason why it doesn't get declared in the codebehind when you
add the runat=server property value?

What I want to do is add an attribute the form.

Thank You for your help it is much appreciated.

Nov 19 '05 #4
As the Form is a Control in the page, you can modify it the same way that
you would modify any other Control in the Page. Create a reference to it
using Page.FindControl as I mentioned, and then have your way with it! ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"Chris Lane" <Ch*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
Thanks

Is there any reason why it doesn't get declared in the codebehind when you
add the runat=server property value?

What I want to do is add an attribute the form.

Thank You for your help it is much appreciated.

Nov 19 '05 #5

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

Similar topics

0
by: Henry | last post by:
Hi Is there any good ideas how to update form vb code always after some values are changed / added by vb (not user). I have some code behind subforms vb and there are calculations behind...
8
by: Colleyville Alan | last post by:
I have been working on an Access app that takes info from a file and writes it to a spreadsheet on a form, simultaneously saving the spreadsheet to Excel. I got the idea that the same concept...
1
by: Machi | last post by:
let say i have a web form with a button on it ... when i click the button, it will pop up one small window to allow me to save a pdf file, everything is done using code behind as below ... however,...
5
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my...
6
by: William Parker | last post by:
I have a web control I made called header.ascx. It has its own properties and methods I defined. But I cannot figure out how to access this control from my code behind page. I can create the...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
3
by: Mr Newbie | last post by:
I am messing around with Web User Controls at present and (think) I have discovered the following. 1.) The identifier for the control in the code behind must match the ID for the control on the...
1
by: DoctorV3774 | last post by:
We developed a small test database that we are using to attempt to connect to a wsdl to consume web services. The database form contains 3 fields and a submit button on the form. At the bottom I've...
0
by: sdanda | last post by:
Hai i am working on vb.net. In my application I created four forms.Those are first.vb,f1.vb,f2.vb and f3.vb In firstvb I added 3 checkboxes and a "display" button.The 3 checkboxes are used to...
0
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...
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: 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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.