following is what i would do.. (code below is c#)
1 ) Declare a public variable in code behind
public string m_strLoadVariable = "";
2) Assign value to public variable from function / event handlers
if(DataType=0)
m_strLoadVariable = "0";
else
m_strLoadVariable = "1";
3) At client side HTML change body tag to
<body onload="LoadRoutine(<%=m_strLoadVariable%>)">
Other option is to check if Page.RegisterStartupScript will work for your
scenario
if(DataType=0)
strLoadVariable = "0";
else
strLoadVariable = "1";
StringBuilder strScript = new StringBuilder();
strScript.Append("<script language=JavaScript>");
strScript.Append("LoadRoutine(" + strLoadVariable + ");");
strScript.Append("</script>");
Page.RegisterStartupScript("LoadScript",strScript. ToString());
Pls let me know if any Questions
Sreejith
"UJ" wrote:
I have some javascript code that I need to run based on a value I know at
the server when I load a page. How can I do an onload event call with a
condition value from the server. (The reason is depending on how the page is
loading - with pre-loaded values or just the defaults) So in a sense what I
want to do is something like:
if me.DataType = 0 then
<body onload="LoadRoutine(0)">
else
<body onload="LoadRoutine(1)">
end if
I'm doing stuff in the javascript that I want to do on the client side but
need to set up stuff initially depending on the fields from the server side.
Hope this makes sense.
TIA - Jeffrey.