young_nacs
asked on
How to communicate between javascript and code behind to share value of client control in asp.net and ajax?
I designd A.aspx, A.ascx and A.customControl.js. in order to distinguish the mode of function call B(filepath), I have to save mode in client page as hidden input field by javascript first and call B(filepath). (B() is a SDK of 3rd party which I don't have control of this.) in code behind page, I like to retrieve mode value from client page (browser) to decide mode. How can I do that? here is the sample code on each page. I am also using ajax from javascript.
[A.aspx]
<input type="image" src="i22a.gif" name="Draft1" value="Draft1" id="_Draft1" onclick="callB(this, '0'); return false;" >
<input type="image" src="i44a.gif" name="Draft2" value="Draft2" id="_Draft2" onclick="callB(this, '1'); return false;" >
[A.ascx]
<input id="Commandcache" type="hidden" runat="server" size="21" />
[A.customControl.js]
function callB(s,t){
var x = document.getElementById('C ommandcach e');
x.value = t;
CreateB(s); //Ajax remote function to call server side function
}
[A.ascx.cs]
public bool CreateB(string s)
{
string cache = this.Commandcache.Value; //error: always return null or empty value
// I don't know this value is always empty even thought I set the value from javascript before call this function.
}
Question: how to send update value when I post new command execute from client to server when I use Ajax feature for partial upate of the page?
Thanks
[A.aspx]
<input type="image" src="i22a.gif" name="Draft1" value="Draft1" id="_Draft1" onclick="callB(this, '0'); return false;" >
<input type="image" src="i44a.gif" name="Draft2" value="Draft2" id="_Draft2" onclick="callB(this, '1'); return false;" >
[A.ascx]
<input id="Commandcache" type="hidden" runat="server" size="21" />
[A.customControl.js]
function callB(s,t){
var x = document.getElementById('C
x.value = t;
CreateB(s); //Ajax remote function to call server side function
}
[A.ascx.cs]
public bool CreateB(string s)
{
string cache = this.Commandcache.Value; //error: always return null or empty value
// I don't know this value is always empty even thought I set the value from javascript before call this function.
}
Question: how to send update value when I post new command execute from client to server when I use Ajax feature for partial upate of the page?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dear young_nacs,
Yes, it depend what u want to solve there. You can refer the tutorial from here: http://ajax.schwarz-interactive.de/csharpsample/default.aspx. Let me know if you need any further assistance.
Yes, it depend what u want to solve there. You can refer the tutorial from here: http://ajax.schwarz-interactive.de/csharpsample/default.aspx. Let me know if you need any further assistance.
ASKER