473,652 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hidden field options

Joe
Hello All:

I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from a
base class called BasePage.aspx. BasePage.aspx has no user interface but
inherits System.Web.UI.P age (BasePage performs security checks in the
Page_Load ... Handles MyBase.Load event). BasePage also has a hidden field
(hdnSessionId) that I want to use to cache a sessionId (client requirement).
I can not use Session, ViewState or QueryString to cache this value (client
requirement).

Here's my question: How do I reference hdnSessionId from within
WebForm1.aspx and WebForm2.aspx? I'm pretty sure that I can do this.
hdnSessionId is in WebFrom1's parent class.

I'm sure that this is somewhat straightforward . I'm also sure that it
involves the MyBase.Controls collection. I'm just not sure how to proceed
when drilling upward in lieu of drilling downward when looking for a control.

Any help would be appreciated.

TIA,
--
Joe
Feb 7 '06 #1
4 1734
Your question is not clear.

It should work as you described it.
If BasePage.aspx defines
protected HiddenField f;

you should be able to reference it in the WebForm1 and WebForm2.
the only thing is that you must have in both pages in HTML the hidden field
with id=f;
PS: you might look at RegisterHiddenF ield method of the page to automaticly
insert hidden field into HTML.

George
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
Hello All:

I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from a
base class called BasePage.aspx. BasePage.aspx has no user interface but
inherits System.Web.UI.P age (BasePage performs security checks in the
Page_Load ... Handles MyBase.Load event). BasePage also has a hidden
field
(hdnSessionId) that I want to use to cache a sessionId (client
requirement).
I can not use Session, ViewState or QueryString to cache this value
(client
requirement).

Here's my question: How do I reference hdnSessionId from within
WebForm1.aspx and WebForm2.aspx? I'm pretty sure that I can do this.
hdnSessionId is in WebFrom1's parent class.

I'm sure that this is somewhat straightforward . I'm also sure that it
involves the MyBase.Controls collection. I'm just not sure how to proceed
when drilling upward in lieu of drilling downward when looking for a
control.

Any help would be appreciated.

TIA,
--
Joe

Feb 7 '06 #2
Joe
Hi George,

Please see below.
--
Joe
"George Ter-Saakov" wrote:
Your question is not clear. Let em rephrase my question: how do I reference a control in a parent form
from within the child form if child form inherits parent form?
It should work as you described it.
If BasePage.aspx defines
protected HiddenField f; I've got this.
you should be able to reference it in the WebForm1 and WebForm2.
the only thing is that you must have in both pages in HTML the hidden field
with id=f; I don't understand this. Would you please re-explain?

PS: you might look at RegisterHiddenF ield method of the page to automaticly
insert hidden field into HTML. I will look at this.

George
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
Hello All:

I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from a
base class called BasePage.aspx. BasePage.aspx has no user interface but
inherits System.Web.UI.P age (BasePage performs security checks in the
Page_Load ... Handles MyBase.Load event). BasePage also has a hidden
field
(hdnSessionId) that I want to use to cache a sessionId (client
requirement).
I can not use Session, ViewState or QueryString to cache this value
(client
requirement).

Here's my question: How do I reference hdnSessionId from within
WebForm1.aspx and WebForm2.aspx? I'm pretty sure that I can do this.
hdnSessionId is in WebFrom1's parent class.

I'm sure that this is somewhat straightforward . I'm also sure that it
involves the MyBase.Controls collection. I'm just not sure how to proceed
when drilling upward in lieu of drilling downward when looking for a
control.

Any help would be appreciated.

TIA,
--
Joe


Feb 7 '06 #3
The ASP.NET automatically "connects" member variable of your class to
instances of the object that represent that HTML field (with runat=server
set).

So if you have a member variable

protected HtmlInputHidden myVariable;

and in your HTML you have
<input type="hidden" id="myVariable " runat=server>
then ASP.NET will automatically create an object with type HtmlInputHidden
and assign it to variable myVariable. And it will represent the HTML code
<input type....>
So if you have in BasePage class defined hidden variable (it must be
declared as protected) myVariable you must have corresponding HTML
<input type="hidden" id="myVariable " runat=server>
in the HTML of WebForm1 and WebForm2

George.

"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:F4******** *************** ***********@mic rosoft.com...
Hi George,

Please see below.
--
Joe
"George Ter-Saakov" wrote:
Your question is not clear.

Let em rephrase my question: how do I reference a control in a parent form
from within the child form if child form inherits parent form?

It should work as you described it.
If BasePage.aspx defines
protected HiddenField f;

I've got this.

you should be able to reference it in the WebForm1 and WebForm2.
the only thing is that you must have in both pages in HTML the hidden
field
with id=f;

I don't understand this. Would you please re-explain?


PS: you might look at RegisterHiddenF ield method of the page to
automaticly
insert hidden field into HTML.

I will look at this.

George
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
> Hello All:
>
> I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from
> a
> base class called BasePage.aspx. BasePage.aspx has no user interface
> but
> inherits System.Web.UI.P age (BasePage performs security checks in the
> Page_Load ... Handles MyBase.Load event). BasePage also has a hidden
> field
> (hdnSessionId) that I want to use to cache a sessionId (client
> requirement).
> I can not use Session, ViewState or QueryString to cache this value
> (client
> requirement).
>
> Here's my question: How do I reference hdnSessionId from within
> WebForm1.aspx and WebForm2.aspx? I'm pretty sure that I can do this.
> hdnSessionId is in WebFrom1's parent class.
>
> I'm sure that this is somewhat straightforward . I'm also sure that it
> involves the MyBase.Controls collection. I'm just not sure how to
> proceed
> when drilling upward in lieu of drilling downward when looking for a
> control.
>
> Any help would be appreciated.
>
> TIA,
> --
> Joe


Feb 7 '06 #4
Joe
Thanks George.

So your saying that ASP.NET will automatically connect the hidden field in
the base page with the hidden fields in the child pages if they have the same
HTML declarations?

Did I get that right?
--
Joe
"George Ter-Saakov" wrote:
The ASP.NET automatically "connects" member variable of your class to
instances of the object that represent that HTML field (with runat=server
set).

So if you have a member variable

protected HtmlInputHidden myVariable;

and in your HTML you have
<input type="hidden" id="myVariable " runat=server>
then ASP.NET will automatically create an object with type HtmlInputHidden
and assign it to variable myVariable. And it will represent the HTML code
<input type....>
So if you have in BasePage class defined hidden variable (it must be
declared as protected) myVariable you must have corresponding HTML
<input type="hidden" id="myVariable " runat=server>
in the HTML of WebForm1 and WebForm2

George.

"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:F4******** *************** ***********@mic rosoft.com...
Hi George,

Please see below.
--
Joe
"George Ter-Saakov" wrote:
Your question is not clear.

Let em rephrase my question: how do I reference a control in a parent form
from within the child form if child form inherits parent form?

It should work as you described it.
If BasePage.aspx defines
protected HiddenField f;

I've got this.

you should be able to reference it in the WebForm1 and WebForm2.
the only thing is that you must have in both pages in HTML the hidden
field
with id=f;

I don't understand this. Would you please re-explain?


PS: you might look at RegisterHiddenF ield method of the page to
automaticly
insert hidden field into HTML.

I will look at this.

George
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:5C******** *************** ***********@mic rosoft.com...
> Hello All:
>
> I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from
> a
> base class called BasePage.aspx. BasePage.aspx has no user interface
> but
> inherits System.Web.UI.P age (BasePage performs security checks in the
> Page_Load ... Handles MyBase.Load event). BasePage also has a hidden
> field
> (hdnSessionId) that I want to use to cache a sessionId (client
> requirement).
> I can not use Session, ViewState or QueryString to cache this value
> (client
> requirement).
>
> Here's my question: How do I reference hdnSessionId from within
> WebForm1.aspx and WebForm2.aspx? I'm pretty sure that I can do this.
> hdnSessionId is in WebFrom1's parent class.
>
> I'm sure that this is somewhat straightforward . I'm also sure that it
> involves the MyBase.Controls collection. I'm just not sure how to
> proceed
> when drilling upward in lieu of drilling downward when looking for a
> control.
>
> Any help would be appreciated.
>
> TIA,
> --
> Joe


Feb 7 '06 #5

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

Similar topics

1
2208
by: Roy Adams | last post by:
Hi Group I'm trying to write from dynamically created hidden fields to a txt field in the onchange event handler within a select. basically the number for the for loop is generated by a field from a db which creates hidden fields populated by prices once the onchange handler fires it sets the text for the text field price and the hidden field Tsize, but I can't get it to set the txt of oldprice from the hidden field prevprice.
3
2194
by: Roy Adams | last post by:
Hi I'm reposting this question because for some reason can't post follow up question to this thread. What I'm trying to do is put the value and text from a a select in to a text field and to a hidden field respectfully and the value from dynamically created hidden fiields in to a text fieldin to a text field all at the same time Here's the code as viewed through the browser <body bgcolor="#FFFFFF" text="#000000" > <SCRIPT...
4
1405
by: john woo | last post by:
Hi I got a question in a form. that's: <TABLE WIDTH="100%" BORDER=0><TD align="Left" width="19%" > <select name="DEPARTMENT" SIZE ="1" style="width:200px;" onChange="Change()"> <option value="0"> &lt;ALL&gt <option value="1000012" >Food Sales ....
2
2469
by: Kostas | last post by:
I ve been told from Allen and others that when enforcing referential integrity Access creates a hidden index for the foreign key, therefore, I do not need to re-index it myself. However, I noticed that if the foreign key has the same name as the name of the field to which it corresponds in the other table, then it appears as indexed in the indexes list. For example: Table PERSON. Field: PersonID
4
2890
by: Greg Bell | last post by:
Hi, Can someone tell me where to look to enable me to read "Folder Options" user settings for hidden/system files from within C#/VB.Net/Any other .NET language. I'm pretty sure it must be part of the framework, but I'm buggered if I can figure out which part. I've tried googling for it, but to no avail. Any ideas? Thanks
3
1478
by: Microsoft_Public | last post by:
All I'm getting is <null>...... I have a legacy input form that I must maintain for a few more months until the balance of the site can be converted to .Net. I need the one database field to contain either 0, 1, 2. The form has 2 pairs of radio button fields. If the answer to the first Q is Yes value = 1
351
12946
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and do) occur in any language. These assumptions are generally made because of familiarity with the language. As a non-code example, consider the idea that the faulty code is written by blackguards bent on foulling the language. The term...
5
2753
by: dvwool | last post by:
Hello, Another newbie here... I've been trying to make this work for days now and have finally decided to post as I can't seem to get it to work. Here's what I'm trying to do... I have a select box with three options and a separate hidden field. The value of a hidden field is dependent upon which of the three options is selected. For example, the three select options are 1, 2, 3... if 1 is selected, the value of the hidden field is...
1
1662
by: Anne Marie | last post by:
I am updating a hidden fields' value client side in javascript. The assigned value seems to be correct from the alert message but when I postback the page to server side the value assigned to the hidden field does NOT seem to persist. Can anyone give me an idea of what I am doing that is iincorrect? I was under the impression that there were a few options for storing information on the client side for the server. One of these options was a...
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.