Hi guys
I have one doubt. We can pass parameters from javascript to asp.net using
callback.Can we pass parameters from asp.net code behind to javascript?
Anyone give example and tell how is possible?
Thanks
Failing to plan is Planning to fail:)
Printable View
Hi guys
I have one doubt. We can pass parameters from javascript to asp.net using
callback.Can we pass parameters from asp.net code behind to javascript?
Anyone give example and tell how is possible?
Thanks
Failing to plan is Planning to fail:)
Yep. A quick search turned up these:
http://aspalliance.com/851
http://forums.asp.net/p/295952/295952.aspx
Hope they help.
Hi buddy,
Thanks to reply.Bcz i am expecting for ur reply.
I saw one article.They told that not possible.I give the link below.
Can we discuss about that?
http://www.velocityreviews.com/forum...avascript.html
Thanks
Fail to plan is Planning to fail.
I think post #2 in your link explains it well.
Does that make sense?Quote:
It is impossible to pass a variable value from the server to the client.
Server-side code executes on the server. Client-side code executes on the
client.
That said, it is certainly possible to WRITE client-side scripting code
(which will be executed on the client) dynamically from the server side.
That is what you need to do.
--
HTH,
Kevin Spencer
Microsoft MVP
And I think that my first link: http://aspalliance.com/851 explains how to write the dynamic JavaScript on the server side.
However, I am not well experienced in this area, so perhaps somebody else can help us both out if there is anything further. :thumb:
Yes you can pass parameters from code behind and even control the postback of the page!!
Typo
Code-behindHTML Code:function getParamsFromServer(value)
{
if(value == '12345')
{
alert('You entered: " + value + ". Expect PostBack!!');
return true;
}
else
{
alert('You entered: " + value + ". There is now NO PostBack!!');
return false;
}
}
.
.
.
.
<!--html section-->
<asp:Button id="btnPassParams" runat="server" />
Code://in the Page_load event
if (!Page.IsPostBack)
{
//in the highlighted part, enter 12345 instead of what is present and see the difference
btnPassParams.Attributes.Add("onclick", "if(getParamsFromServer('asdfsdfsd')) return true; else return false;");
}
Cool Harsh. :thumb:
I'm excited to try something like that out.