Click here to Skip to main content
15,848,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a input box for get the student name from user, Which has AutoComplete Extender in Javascript. If I Select any value in that Input box, I have to call some function like textbox textchanged event. How to do it? please help me

That event has following...
if (ddlUserType.SelectedItem.Text.ToUpper() == "STUDENT")
{
    string userType = "STUDENT";

    int DueDays = Math.Abs(Convert.ToInt32(objDA.GetDueDaysForStudentOrStaff(userType, Convert.ToInt32(staffstudent), 0)));
    lblDueDays.Text = DueDays.ToString();
    int IncreaseFineAmount = Convert.ToInt32(lblDueDays.Text) / Convert.ToInt32(lblFineAmtSettings.Text);
    //int IncreaseFineAmount = Convert.ToInt32(lblFineAmtSettings.Text) + Convert.ToInt32(lblDueDays.Text);
    if (IncreaseFineAmount > 0)
    {
        FineAmount = Convert.ToDecimal(txtFineAmount.Text) * Math.Abs(IncreaseFineAmount);
        txtFineAmount.Text = FineAmount.ToString();
    }
    else
        txtFineAmount.Text = hFineAmount.Value;
}
else if (ddlUserType.SelectedItem.Text.ToUpper() == "STAFF")
{
    string userType = "STAFF";
    int DueDays = Math.Abs(Convert.ToInt32(objDA.GetDueDaysForStudentOrStaff(userType, 0, Convert.ToInt32(staffstudent))));
    lblDueDays.Text = DueDays.ToString();
    int IncreaseFineAmount = Convert.ToInt32(lblDueDays.Text) / Convert.ToInt32(lblFineAmtSettings.Text);
    //int IncreaseFineAmount = Convert.ToInt32(lblFineAmtSettings.Text) + Convert.ToInt32(lblDueDays.Text);
    if (IncreaseFineAmount > 0)
    {
        FineAmount = Convert.ToDecimal(txtFineAmount.Text) * Math.Abs(IncreaseFineAmount);
        txtFineAmount.Text = FineAmount.ToString();
    }
    else
        txtFineAmount.Text = hFineAmount.Value;

}
Posted
Comments
ZurdoDev 9-Apr-13 7:47am    
I'm confused. Can you show the relevant code and be more specific?

Call a Javascript function onblur of inputbox.
Javascript:
JavaScript
function doPostBack() 
{
     __doPostBack('', "TextChange");
}

Handle it in PageLoad event and call the specific function whichever you want.
CS:
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (Request.Params.Get("__EVENTARGUMENT") != null)
    {
        if (Request.Params.Get("__EVENTARGUMENT").ToString() == "TextChange")
        {
            MyTextChageFunction();
        }
    }
}
private void MyTextChageFunction()
{
     //Write your logic here..
}



Hope it helps!
--Amit
 
Share this answer
 
Comments
UshaCbe 10-Apr-13 0:39am    
Oh my god, That is very nice. Thank you very much. That's Working fine..
_Amy 10-Apr-13 0:47am    
Welcome.. :)
UshaCbe 10-Apr-13 0:45am    
If you don't mind, Can u explain how it works?
_Amy 10-Apr-13 0:46am    
UshaCbe 10-Apr-13 5:41am    
Thank you so much
XML
Use this in you javascript

function LinkClicked(lnk)
{

      __doPostBack("<%= txtAssignedUser.ClientID %>");
}
 
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