Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Can I set a hidden (or other) field on an HTML page from a ASP.NET session variable

Posted on 2005-03-24
9
Medium Priority
?
299 Views
Last Modified: 2010-04-07
Hi,

I have a number of similar questions posted here at the moment as im considering different ways of solving my problem.

I have a value in a ASP.NET session variable that I need to access from the HTML page.  Is there any way (maybe in the onload event?!) of transferring that value to the HTML page?

I dont need this at run time just when it gets loaded/reloaded.

Thanks.

James.
0
Comment
Question by:JAMES
  • 4
  • 2
  • 2
  • +1
9 Comments
 

Expert Comment

by:pbailey100
ID: 13621267
if you want to set a value in the hidden field try placing this code in the html

<input id="Hidden1" type="hidden" value='<%= Session("MyValue") %>' />

Hope this helps
0
 
LVL 9

Expert Comment

by:Type25
ID: 13621521
Sure...

OnLoadEvent
---------------

myHiddenField.Value = Session("MyValue")

HTML
-----

<input type=hidden id=myHiddenField runat=server>
0
 

Author Comment

by:JAMES
ID: 13621561
Type25,

How is that transferring the value in an apsx page session variable to the HTML page?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 26

Assisted Solution

by:Rejojohny
Rejojohny earned 1000 total points
ID: 13621699
is the HTML page loaded within frames and does the other frames have aspx pages .. if s .. then u can do it in the load event of the aspx pages to fill the value .. if the HTML page is loaded on its own .. then u cannot do what u have requested .. change the HTML page to an aspx page .. am sure that will not hamper ur exiting code in that page (if u have any)
0
 
LVL 9

Accepted Solution

by:
Type25 earned 1000 total points
ID: 13621731
OK, if you mean transferring the value to HTML page:

pageload in aspx
-------------------

Page.RegisterStartupScript("fillValue", "<script>document.getElementById('myHiddenText').value = " + Session("myvalue") + ";</script>");
0
 

Author Comment

by:JAMES
ID: 13622101
Rejo,

Interesting thought -change to an aspx page...

We dynamically create a frameset within the HTML page - can this be done in a aspx page?
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 13622168
how do u dynamically create a frameset .. using document.write statements? anyway all HTML/client scripts that u have writte in HTML page can be used in the aspx page too ...
0
 

Author Comment

by:JAMES
ID: 13622485
Just converted to ASPX and so far so good.  This might solve all my problems is getting information to and from pages without using damn cookies....

I will post back after testing.....
0
 

Author Comment

by:JAMES
ID: 13628684
I am going to split points as Type25 gave me an an answer but Rejo gave me the idea the change my html to an aspx page (which has helped me in a number of ways).

Hope you both agree.

Many thanks.

James.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question