469,283 Members | 2,297 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

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 2698
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Machi | last post: by
5 posts views Thread by Richard Dixson | last post: by
6 posts views Thread by William Parker | last post: by
3 posts views Thread by Mr Newbie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.