ponki.d.monkey Posted February 19, 2009 Share Posted February 19, 2009 Hi! I just want to know how to set a session variable from a .ascx file (without a code-behind) using client side script or inline code. The .ascx file was created using dreamweaver, now we're trying to get some values from the .ascx file (using Visual Web Developer) and store those values in a session variable. How do we do it without code-behind? Is it possible? Thanks if anyone can answer this question.... Link to comment Share on other sites More sharing options...
aspnetguy Posted February 19, 2009 Share Posted February 19, 2009 I am not fully understanding what you are asking. Post the code you have so far and I'll try my best to answer your question. Link to comment Share on other sites More sharing options...
ponki.d.monkey Posted February 20, 2009 Author Share Posted February 20, 2009 Hi aspnetguy,The code looks something like this: <script type="text/javascript">//some javascript</script><table width="250" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" align="left" class="glossymenu"> <a class="menuitem submenuheader" href="java script:void(0)" onclick="SomeJavaScriptFunc()">Website Development</a> <a class="menuitem submenuheader" href="java script:void(0)" onclick="SomeJavaScriptFunc()">e-Commerce</a> </td> </tr></table> So as you can see it doesn't have a page directive like any usual .ascx or user control file since it was created using dreamweaver. What we want to do is when we click the "Website Development" link, the session variable will be set to "Website Development" else if we click the "e-Commerce" link, it will be set to "e-Commerce." Now the problem is the file doesn't have a code-behind file like any usual .ascx file and we don't want to put a code-behind because it will affect the behavior of the control (since it was created using dreamweaver). We're also aware that we cannot set the session variable through javascript and the only other way we can do it is either by using an inline code or using AJAX. But then again, now that I've thought about it, AJAX still requires a code-behind file. So thinking about, the only option that we have as using inline code. We can just put a page directive then use the script tags. Now, we tried that, but the .ascx file doesn't recognize the script tag. So now, we don't know what other options we have. Any ideas? Thanks for the reply.... Link to comment Share on other sites More sharing options...
Technage Posted February 26, 2009 Share Posted February 26, 2009 I am afraid to say you cannot do this without a code behind. The server holds the session information in memory and all the client side can do is pass the cookie which is the session key back and forth. So unless you go with cookies or something yourself to determine what you are doing you will not be able to achieve what you want. Another option is the AJAX you spoke of why are you so against code behind? Link to comment Share on other sites More sharing options...
aspnetguy Posted February 27, 2009 Share Posted February 27, 2009 AJAX is probably your only option without a code behind. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.