I got a property in my code behind, nl "Language" with Get and Set accessors.
On my form I want to put a link (html, not asp) who's target is a javascript in my <head> section.
Then I want this Javascript to set the value of my Language property, and in the Set accessor for the property, do some stuff.
Is it possible to set the property in the code behind from your page? Maybe i should just use an asp label running on the server, but I'm trying to see how far i can stay away from anything causing a postback.The Language property exists in the codebehind. You do realize that at some point, you will have to have a postback so that the property can be assigned that value and perform whatever actions it wants to perform. Get it?
You will eventually have to use some sort of a server-side control for this. Here's what I would suggest.
Add a hidden field to your page. When the user clicks on the hyperlink, the javascript function assigns a value to that hidden field. When the page posts back, in the page load event, assign the value of the hidden field to your property. Then let the property do whatever with it.
No, you cannot avoid the postback as far as you've described your setup.
Actually I was stupid anyhow. When hte language change, I got to reload the form with the different language.
I never use hidden fields though. Nevermind
Thanks for reply M.
No prob.
Just been thinking.
What if one do want to set a code behind property from the page?
What if you do want to call a code behind fucntion from a javascript, sitting in hte head section, called by for instance a link clicked?
The answer to your first question is above ^^
The answer to your second question is a little complex. You will need to use javascript to force a postback. You can do this in one of two ways. For example, if you want to call a button's click event, you can call it like
document.getElementById('buttonid').click();
The second way to do this is quite generic. You can use javascript to force a postback.
http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment