473,386 Members | 1,736 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,386 software developers and data experts.

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.Page (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 1723
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 RegisterHiddenField method of the page to automaticly
insert hidden field into HTML.

George
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.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.Page (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 RegisterHiddenField method of the page to automaticly
insert hidden field into HTML. I will look at this.

George
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.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.Page (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*@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.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 RegisterHiddenField method of the page to
automaticly
insert hidden field into HTML.

I will look at this.

George
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.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.Page (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*@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.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 RegisterHiddenField method of the page to
automaticly
insert hidden field into HTML.

I will look at this.

George
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.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.Page (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
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...
3
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...
4
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...
2
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...
4
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...
3
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...
351
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...
5
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...

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.