Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to grab a hidden value

Status
Not open for further replies.

smellykat

Programmer
Mar 4, 2002
33
US
I'm fairly new to .net, so please don't flame me.

This is what I'm trying to achieve: I'd like to create a hidden variable that will tell me whether I'm on the homepage or any other page...this is my hidden var:
<input type="hidden" name="IsDefault" value="TRUE" >

Now, I'd like to grab the value of IsDefault and depending on whether it is true or not, display certain content.

This is what I have in my corresponding .vb:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim str1 As String
str1 = Request.Item("isDefault")

End Sub


This is obviously wrong.

Any tips, suggestions?
 
Although not directly answering your question, this may provide an alternative. Rather than create a hidden input, why not just use a Servervariable as these already exist. e.g.
Code:
If Request.ServerVariables("PATH_INFO") = "MyWebsite/MyHomePage.aspx" Then
	' Do Something
End If


----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Thanks for your answer,ca8msm.

The reason I can't use servervariables is because the url does now always reflect that the user is on the homepage. For example, the first time they come to the site, all they see is the url of the site (ie. even though they've actually landed on /default.aspx.
 
Thanks for your answer,ca8msm.

The reason I can't use servervariables is because the url does not always reflect that the user is on the homepage. For example, the first time they come to the site, all they see is the url of the site (ie. even though they've actually landed on /default.aspx.
 
That doesn't matter - the PATH_INFO variable will tell you which page the user is on not what the url says.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Also, where will this code be running from? Are you placing this in a class or just running it from a page?

If you are running it from the page load (like it looks like you are from your example) then why? Surely you wouldn't have to check which page it is - you would just put the code you want to execute only in your default.aspx page.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
tip,
aspx
<asp:TextBox ID="IsDefault" runat="server" ></asp:TextBox>

codebehind
IsDefault.Attributes.Add("style", "DISPLAY: none;")

or you could use CSS in just the aspx
in the head tags
<style>.hide { DISPLAY: none }
</style>

<asp:TextBox ID="IsDefault" runat="server" CssClass="hide" ></asp:TextBox>

To get it's value IsDefault.Text


suggestion, think about ca8msm suggestion.

Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top