Retain session values to html pages [Resolved]

Posted by jayanthichebrolupanoramicworldbiz-8895 under ASP.NET on 2/10/2011 | Points: 10 | Views : 2879 | Status : [Member] | Replies : 13
Hi,

Is there any way to get session values from an aspx page to html page.Actual page is aspx page only but redirecting to html page when i use sessions in that page giving object reference error




Responses

Posted by: jayanthichebrolupanoramicworldbiz-8895 on: 2/11/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Thanks for all your replies.I achieved this through cookies.Now it is working.

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

Yes, you can pass those sessions values thru querystring to html page, Make sure the details are not confidential data as in querystring its visible to the outer world.

Regards
Madhu

Thanks and Regards
Madhu

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi Madhu,

Can u post an example... Once we pass the values as query string to how to retrive in html page?

Thanks
Karthik
www.f5Debug.net

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: jayanthichebrolupanoramicworldbiz-8895 on: 2/10/2011 [Member] Starter | Points: 25

Up
0
Down
Yes my another requirement is to retrieve again from html page

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Yes, there shld be some option to get that... lets wait for madhu's reply...

Thanks
Karthik
www.f5Debug.net

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

In javascript we have something called window.location.search.substring(1) to access the passed querystring parameters

try this sample as below I have coded with html only ... aply the same logic for other cases also.

<html>
<script language="javascript>
var str=window.location.search.substring(1);
alert(str);
</script>
<body>
<form action="test.html">
<input type="text" name="myParam1" />
<input type="submit" />
</form>
</body>
</html>

Save this as test.html and execute to see the result.

Regards
Madhu

Thanks and Regards
Madhu

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

You may use ViewState I think!!

Thanks

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: jayanthichebrolupanoramicworldbiz-8895 on: 2/10/2011 [Member] Starter | Points: 25

Up
0
Down
How can we pass values from one page to another using viewstate

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
u just use/Set the "previouspage" property in the which page u wanted .
example (form 1 u have the "testbox1"

u want to access the value of textbox1 from default1.aspx"

so now u u open default2.aspx

in the code behind just set the following code

page obj=this.previouspage;
testbox txtobj=obj.findcontrol("textbox1");// here u get the data from page1 to page2
string str=txtobj.text;

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Between aspx pages its fine... but we need to have it from ASPX to HTML

Thanks
Karthik
www.f5Debug.net

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: jayanthichebrolupanoramicworldbiz-8895 on: 2/10/2011 [Member] Starter | Points: 25

Up
0
Down
My controls(suppose username& password) are in master pages that too different master pages i can able to allow them to login from any page and once he logged in displaying his specific options on the top across the pages this i achieved through session except the case when html pages in the application. If i use cookies its working but i need to change all the pages or any other alternate is there

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 2/10/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
What you can do is to have one single master html page, define framesets and load all your other html pages in that, that way you dont have to change in all the html pages anymore.

regards
Madhu

Thanks and Regards
Madhu

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/11/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Good one!!! If your data is not sensitive then cookie would be a good option!!!

Thanks
Karthik
www.f5Debug.net

jayanthichebrolupanoramicworldbiz-8895, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response