How to pass argument to the RaiseCallbackEvent? [Resolved]

Posted by Laghaterohan under Regular Expressions on 4/21/2011 | Points: 10 | Views : 5513 | Status : [Member] | Replies : 2
Hello,

I have a textbox where in the roll number is entered ;on blur of which i want this textbox value to be pass to server side...how to achieve this? Please help....


public void RaiseCallbackEvent(string eventArgument) //Here , when my blur event fires this method is called and eventArgument is 'undefined' because of which my callback fails.....please help...how to pass value here????
{

}

Best Regards,
Rohan Laghate



Responses

Posted by: Laghaterohan on: 4/21/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Thank You!!!!

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 4/21/2011 [Member] Starter | Points: 25

Up
0
Down
In the ASPX Page

<script type="text/javascript" language="javascript">

function ReceiveServerData(arg, context) {
document.getElementById('<%=yourtextbox.ClientID %>').value = arg;
}
function ProcessCallBackError(arg, context) { }
function OnTextblur() {
CallTheServer(document.getElementById('<%=yourtextbox.ClientID %>').value);
}
</script>

In you code behind page

private string MyArgument;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

ClientScriptManager cs = Page.ClientScript;

String cbReference = cs.GetCallbackEventReference("'" + Page.UniqueID + "'", "arg", "ReceiveServerData", "", "ProcessCallBackError", false);
String callbackScript = "function CallTheServer(arg, context) {" + cbReference + "; }";
cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer", callbackScript, true);
}

public void RaiseCallbackEvent(String eventArgument)
{
try
{
MyArgument = !String.IsNullOrEmpty(eventArgument) ? eventArgument.Trim() : string.Empty;
//Process the eventArgument
}
catch {}
}
public string GetCallbackResult()
{
return MyArgument;
}


Thanks,
Debata



Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response