tags:

views:

18

answers:

2

I have some ajax fucntions on my default.aspx that I use for saving data to my db. I have the form on my web control. When I try calling the function from my button which resides on the web control. I get an error.

I need to call that function from my registerform.ascx. How do I do that from within the registerform code behind?

function ShowAvailability() {
$.ajax({
    type: "POST",
    url: "Default.aspx/CheckEmail",
    data: '{usermail: "' + $("#<%=subs_email.ClientID%>")[0].value + '" }',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: OnSuccess,
    failure: function(response) {
        alert(response);
    }
});
A: 

use ButtonID.Attributes.Add("onclick", "ShowAvailability()");
if this wont work provide the detail of the error u r getting.

stacknewbee
'ASP.controls_comment_ascx' does not contain a definition for 'ShowAvailability' and no extension method 'ShowAvailability' accepting a first argument of type 'ASP.controls_comment_ascx' could be found (are you missing a using directive or an assembly reference?)
Kenyana
A: 

It seems I was doing it all wrong. This code seems to be working:

OnClientClick="return ShowAvailability()"

Initially I had onClick

Kenyana