Call a server function from javascript
-
How can I force a postback and call a codebehind function from javascript? I want to do something like this: aspx-file
<script type="text/javascript">
function OnRowSelecting(sender, args)
{
ServerFunc();
}
</script>Codebehind c# file
private void ServerFunc()
{
//…
}_____________________________ ...and justice for all
-
How can I force a postback and call a codebehind function from javascript? I want to do something like this: aspx-file
<script type="text/javascript">
function OnRowSelecting(sender, args)
{
ServerFunc();
}
</script>Codebehind c# file
private void ServerFunc()
{
//…
}_____________________________ ...and justice for all
How I usually do this which may not be the best method. Drag a button on your form. Double Click it to get your server side code method. In the pageload hide the button from the user by adding the following:
this.Button1.Style.Add("display", "none");
Put your code server side in the button click's event. Then Add the following javascript to your page.function CallServerMethod() { var Button1 = document.getElementById("<%=Button1.ClientID %>"); Button1.click(); }
Now you can use the javascript "CallServerMethod()"I didn't get any requirements for the signature
-
How can I force a postback and call a codebehind function from javascript? I want to do something like this: aspx-file
<script type="text/javascript">
function OnRowSelecting(sender, args)
{
ServerFunc();
}
</script>Codebehind c# file
private void ServerFunc()
{
//…
}_____________________________ ...and justice for all
-
How can I force a postback and call a codebehind function from javascript? I want to do something like this: aspx-file
<script type="text/javascript">
function OnRowSelecting(sender, args)
{
ServerFunc();
}
</script>Codebehind c# file
private void ServerFunc()
{
//…
}_____________________________ ...and justice for all
You realise that there's no way to do this without making an AJAX call ( which requires it's own set of work ) or refreshing the entire page ?
Christian Graus Driven to the arms of OSX by Vista.
-
How I usually do this which may not be the best method. Drag a button on your form. Double Click it to get your server side code method. In the pageload hide the button from the user by adding the following:
this.Button1.Style.Add("display", "none");
Put your code server side in the button click's event. Then Add the following javascript to your page.function CallServerMethod() { var Button1 = document.getElementById("<%=Button1.ClientID %>"); Button1.click(); }
Now you can use the javascript "CallServerMethod()"I didn't get any requirements for the signature
I dunno why someone gave this less than 5, it's the only real way to do it.
Christian Graus Driven to the arms of OSX by Vista.
-
Not if he wants to call a specific event, no.
Christian Graus Driven to the arms of OSX by Vista.
-
I dunno why someone gave this less than 5, it's the only real way to do it.
Christian Graus Driven to the arms of OSX by Vista.
Thanks for the support. :)
I didn't get any requirements for the signature
-
How I usually do this which may not be the best method. Drag a button on your form. Double Click it to get your server side code method. In the pageload hide the button from the user by adding the following:
this.Button1.Style.Add("display", "none");
Put your code server side in the button click's event. Then Add the following javascript to your page.function CallServerMethod() { var Button1 = document.getElementById("<%=Button1.ClientID %>"); Button1.click(); }
Now you can use the javascript "CallServerMethod()"I didn't get any requirements for the signature
You got my :thumbsup: vote It works perfect for me. About AJAX I luckily easily find a solution using our telerik-framework to avoid the whole page to refresh.
_____________________________ ...and justice for all
-
You got my :thumbsup: vote It works perfect for me. About AJAX I luckily easily find a solution using our telerik-framework to avoid the whole page to refresh.
_____________________________ ...and justice for all
That's funny that you mentioned Telerik. I came up with that solution in order to search the radcombobox. I posted the code Telerik's website. http://www.telerik.com/community/code-library/aspnet-ajax/combobox/searching-in-a-combobox-using-radwindow.aspx[^]
I didn't get any requirements for the signature