Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have textbox in updatepanel .when i enter name in textbox ,it will check whether name is in database or not.If name is exsist in database ,then near textbox massage will be display " name already exsist".
what i have to do for this?
Posted

1 solution

This isnt using an update panel but it will/should do the same thing if i understand your question correctly.

JQuery

JavaScript
$('#IdOfYourTextBox').keydown(function()
{
	var dataToSend={Send1:$("#IdOfYourTextBox").val(), Method:'CheckDB' };
 
		var opts =
		{
			url: '<%=ResolveUrl("~/YourCodeBehindFile.aspx") %>',
			data: dataToSend,
			dataType: 'JSON',
			type: 'POST',
			success: function (response) {
				//Do something here based on if the results meet your criteria
				//Set textbox back ground color to red or something
				$("#IdOfYourTextBox").css({"background-color": "green"});
				$("#IdOfHiddenReturnMsgDiv").html("Success!");
			}
		}
		$.ajax(opts);
});


Your code behind file

C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        if (Request.Form["Method"] == "CheckDB")
        {
            CheckDB();
            return;
        }
    }
}

public void CheckDB()
{
    //Do code here to check for name and if it exists, return a value if need be...change void to return value.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900