views:

1918

answers:

5

I have a database that stores events in it and a page with a calendar object on it. When rendering the days it looks through the months events and if any match the current day being rendered it creates a linkbutton to represent the event in the day on the calendar and adds it to that cell. I add some javascript to the linkbutton to change the window.location to a page to view event details passing EventID in the querystring ( I tried setting the postbackurl of the newly created linkbutton but it wasnt causing a postback... no luck). I need to set a Session variable ie. Session("EditMode") = "Edit" So the new page will know it is to get an existing event info rather than prepare to create a new event? Any SUGGESTIONS?

+5  A: 

Add another query string variable that the page can use to trigger existing vs new.

Joel Coehoorn
+2  A: 

Your session vars are controlled by the server, JS runs client side, and as such cannot modify the vars directly.

You need to make server requests using POST or GET and hidden iframes, or XMLHTTPRequest() calls to send data from the JS to the server, and then have your server side code handle the vars.

Add another query string variable that the page can use to trigger existing vs new.

Maitus
A: 

You definitely need to add a variable to the target page. But I take it that you are doing a popup scenario, so you should be able to create a javascript function OpenWindow() and fire it off when the user clicks the link.

<script>
function OpenWindow(eventId, editMode)
{
    var window = window.open("popup.aspx?eventId=" + eventId + "&editMode=" + editMode);
}
</script>

On the server side you need to build the call to the OpenWindow function. For example:

onclick="OpenWindow(eventId=" + row["eventId"].ToString() + "&editMode=" + editMode.ToString() + ");"

So in other words, prep everything on the serverside to set your javascript to post all variables to the new page. Hope this helps.

David Robbins
A: 

Just a question about this. As far as I know the session variables are always part of the communication ad definitionem it can be altered by the client side. However I noticed the browsers are the ones who doesn't provide any access to these variable map. So, what's the point of this?

progician
A: 

You have to use server-side programming (vb.net or C# or ...). Maybe is better you use a button in asp.net .

www.valuemymoney.com

<a href="www.valuemymoney.com">value</a>