Reputation: 8661
My Javascript function calling a sever side callback function. This is working fine when I give alert(). If I comment alert() then the browser throw a warning ..
My function is
function callMe(){
var input = 'input parameter list';
var val= <%=gridCtrlUsers.ClientID%>.callbackControl.Callback(input);
// If I comment this alert ,it would throw a browser warning.
alert(val) // This prints true or false
}
Could anyone please help me ?
Upvotes: 2
Views: 841
Reputation:
I agree with José this doesnt look standard.
If its a custom control that has a client side API then have you tried just typing out its identifier rather than using the <% %>
tags...
You havnt mentioned what 3rd party toolkit your using but I know with DevExpress their components (such as the grid) have a property that allows you to set the client side instance name. You can get the grid to then call back from your client code by doing something like gridClientName.PerformCallback()
.
If it is ComponentArt's grid you are using then I think you can set the grids client name with the ClientObjectId
property and then use gridClientName.callback()
in your Javascript.
If you just want to call an ASP.NET function from your Javascript code you could use an ASP.NET Script Manager AJAX control. I will give you an example below...
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
</asp:ScriptManager>
<script runat="server">
[System.Web.Services.WebMethod]
public static String Msg()
{
String userName = "Chalkey";
return userName;
}
</script>
<script type="text/javascript">
PageMethods.Msg(OnSucceed);
function OnSucceed(result)
{
alert(result);
}
</script>
Hope some of this is useful! :)
Upvotes: 2