473,406 Members | 2,371 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,406 software developers and data experts.

Need help with accessing control in inherited form

Joe
Hello All:

I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from
BasePage.aspx. BasePage.aspx inherits System.Web.UI.Page and has one hidden
field (hdnSessionId) that I want to use to cache a value that the web app
needs. I can not use Session, ViewState or QueryString to cache this value
(client requirement). The hidden field is dimmed in the BasePage.aspx.vb
code-behind as Protected WithEvents hdnFormSessionId As
System.Web.UI.HtmlControls.HtmlInputHidden.

Here's my question: How do I reference hdnSessionId from within
WebForm1.aspx and WebForm2.aspx (the child forms that inherit BasePage.aspx)?

Any help would be appreciated.

TIA,
--
Joe
Feb 8 '06 #1
3 1413
If it's protected, you should be able to reference it simply by name.
Protected members, unlike private ones, are available to child-class (the
point of protected).

Karl

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
Hello All:

I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from
BasePage.aspx. BasePage.aspx inherits System.Web.UI.Page and has one
hidden
field (hdnSessionId) that I want to use to cache a value that the web app
needs. I can not use Session, ViewState or QueryString to cache this
value
(client requirement). The hidden field is dimmed in the BasePage.aspx.vb
code-behind as Protected WithEvents hdnFormSessionId As
System.Web.UI.HtmlControls.HtmlInputHidden.

Here's my question: How do I reference hdnSessionId from within
WebForm1.aspx and WebForm2.aspx (the child forms that inherit
BasePage.aspx)?

Any help would be appreciated.

TIA,
--
Joe

Feb 8 '06 #2
Joe
Hi Karl,

Maybe you can help me understand something:

In BasePage.aspx I have an hidden field defined in the HTML as

<INPUT id="hdnSessionId" type="hidden" name="hdnSessionId" runat="server">.

I have an idetical declaration in WebForm1.aspx's HTML.

In BasePage,aspx's code-behind I have declared Protected WithEvents
hdnFormSessionId As System.Web.UI.HtmlControls.HtmlInputHidden. There is no
such declaration in WebForm1.aspx's code-behind.

When I run the code and populate WebForm1.aspx's hidden field, I see the
same value in BasePage.aspx's hidden field (checking with
Ctype(MyBase.FindControl("Form1").FindControl("hdn SessionId"),
HtmlInputHidden).Value in the immediate window). But I see the value without
explicitly populating the hidden field in BasePage.aspx. I don't understand
this.

Do you understand this? Why would I see this behavior?

--
Joe
"Karl Seguin [MVP]" wrote:
If it's protected, you should be able to reference it simply by name.
Protected members, unlike private ones, are available to child-class (the
point of protected).

Karl

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
Hello All:

I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from
BasePage.aspx. BasePage.aspx inherits System.Web.UI.Page and has one
hidden
field (hdnSessionId) that I want to use to cache a value that the web app
needs. I can not use Session, ViewState or QueryString to cache this
value
(client requirement). The hidden field is dimmed in the BasePage.aspx.vb
code-behind as Protected WithEvents hdnFormSessionId As
System.Web.UI.HtmlControls.HtmlInputHidden.

Here's my question: How do I reference hdnSessionId from within
WebForm1.aspx and WebForm2.aspx (the child forms that inherit
BasePage.aspx)?

Any help would be appreciated.

TIA,
--
Joe


Feb 8 '06 #3
Base classes aren't ideal for representing visual elements. You should
consider using a MasterPage instead of your base page.
(http://www.metabuilders.com/Tools/MasterPages.aspx)
There's only 1 hidden field, so wherever you modify it, you'll see the value
reflected.

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
Hi Karl,

Maybe you can help me understand something:

In BasePage.aspx I have an hidden field defined in the HTML as

<INPUT id="hdnSessionId" type="hidden" name="hdnSessionId"
runat="server">.

I have an idetical declaration in WebForm1.aspx's HTML.

In BasePage,aspx's code-behind I have declared Protected WithEvents
hdnFormSessionId As System.Web.UI.HtmlControls.HtmlInputHidden. There is
no
such declaration in WebForm1.aspx's code-behind.

When I run the code and populate WebForm1.aspx's hidden field, I see the
same value in BasePage.aspx's hidden field (checking with
Ctype(MyBase.FindControl("Form1").FindControl("hdn SessionId"),
HtmlInputHidden).Value in the immediate window). But I see the value
without
explicitly populating the hidden field in BasePage.aspx. I don't
understand
this.

Do you understand this? Why would I see this behavior?

--
Joe
"Karl Seguin [MVP]" wrote:
If it's protected, you should be able to reference it simply by name.
Protected members, unlike private ones, are available to child-class (the
point of protected).

Karl

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:8B**********************************@microsof t.com...
> Hello All:
>
> I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from
> BasePage.aspx. BasePage.aspx inherits System.Web.UI.Page and has one
> hidden
> field (hdnSessionId) that I want to use to cache a value that the web
> app
> needs. I can not use Session, ViewState or QueryString to cache this
> value
> (client requirement). The hidden field is dimmed in the
> BasePage.aspx.vb
> code-behind as Protected WithEvents hdnFormSessionId As
> System.Web.UI.HtmlControls.HtmlInputHidden.
>
> Here's my question: How do I reference hdnSessionId from within
> WebForm1.aspx and WebForm2.aspx (the child forms that inherit
> BasePage.aspx)?
>
> Any help would be appreciated.
>
> TIA,
> --
> Joe


Feb 8 '06 #4

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

Similar topics

2
by: Matt | last post by:
I have created an MDI child form that I am using as a base form in a VB.Net MDI application. The base MDI child form has a series of menu options on it. I then use this form to create other MDI...
1
by: Dayne | last post by:
I have a problem with how visual studio.net's form designer handles form inheritance. This is what I am trying to do.. I have a base form with some controls on it..I then create a child Form from...
0
by: ABC | last post by:
I write a Base Web User Control which contains several public properties and a Inherited Web User Control which only have some codes in new method. When I use the Inherited Web User Control on Web...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
4
by: rajendra | last post by:
how to extend existing windows forms control like if i want to add new add method to combo box ,how to go abt. it? can anyone help me abt. this
4
by: JC Voon | last post by:
Hi: My base form has a button, when click it will call MessageBox.Show( "Base form" ). I inherite a child form from the base and assign a button click event to the same button which will call...
7
by: crowl | last post by:
VS.2003, .NET Framework 1.1, C# My goal: Creating a dll (helper.dll) which contains some UserControls and some other helpful classes in order to use it in other projects. Symtoms: The...
1
by: ben m | last post by:
Hi all - we've recently switched up to 2005, and I'm having trouble getting the hang of some things, among them, creating a control for the project. Currently, we use a combination of controls on a...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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,...
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.