Need help with accessing control in inherited form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,
 
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
 
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("hdnSessionId"),
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?
 
Back
Top