472,353 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 2809
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...
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...
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...
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...
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...
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...
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...
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...
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.