We help IT Professionals succeed at work.

Button Click using JQUERY

ASPNET_8
ASPNET_8 asked
on
I hav a button in aspx page

 <asp:Button ID = "btn_CheckAvailibility"  runat ="server" Text="Check Availibility"
                                onclick="btn_CheckAvailibility_Click" />

I want to handle the onclick event of this button using jquery.
 right now the button click is refreshing the page.Code for Onclick event is

protected void btn_CheckAvailibility_Click(object sender, EventArgs e)
    {
        objBuyerInfo.User_Name = General.SetInputIntoDB(txt_User_Name.Text);
        DataSet ds = objBuyerInfo.SelectByName();
            if(ds.Tables[0].Rows[0]["Record"].ToString() != "0")
            {
                txt_User_Name.Text = "";
                lblMsg.Text = "<b>Login Name already exists,Please try another.</b>";
            }
    }


Thanks
Comment
Watch Question

$("#btn_CheckAvailibility").click(function() {

objBuyerInfo.User_Name = General.SetInputIntoDB(txt_User_Name.Text);
        DataSet ds = objBuyerInfo.SelectByName();
            if(ds.Tables[0].Rows[0]["Record"].ToString() != "0")
            {
                txt_User_Name.Text = "";
                lblMsg.Text = "<b>Login Name already exists,Please try another.</b>";
            }


});

Author

Commented:
Where shud i include this code and how shud i call this function??
instead of your code ;call this code.check alert is coming or not.

$(document).ready(function () {
$("#btn_CheckAvailibility").click(function() {

alert("aaa")
objBuyerInfo.User_Name = General.SetInputIntoDB(txt_User_Name.Text);
        DataSet ds = objBuyerInfo.SelectByName();
            if(ds.Tables[0].Rows[0]["Record"].ToString() != "0")
            {
                txt_User_Name.Text = "";
                lblMsg.Text = "<b>Login Name already exists,Please try another.</b>";
            }


});
});

Author

Commented:
OK

Explore More ContentExplore courses, solutions, and other research materials related to this topic.