0

i'm making a web app on asp.net and i need to call this method:

 protected void fillList() {
        string strSql;
        dato = Convert.ToInt32(hiddenControl.Value);
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString());
        conn.Open();
        strSql = "SELECT DISTINCT something FROM table WHERE data = " + dato;
        SqlCommand camAND = new SqlCommand(strSql, conn);
        System.Data.DataTable tablainc = new System.Data.DataTable();
        camAND.CommandTimeout = 36000;
        tablainc.Load(camAND.ExecuteReader());


        foreach (DataRow dtr in tablainc.Rows)
        {
            list.Items.Add(dtrw[0].ToString());  
        }

    }

That method is for insert items on listbox , i need do that when the javascript event OnBlur happens, this is my JS function:

 function frmt_Date() {
var text = document.getElementById("txperiodo").value;
var newText = text.replace("/", "");
document.getElementById("hiddenControl").value = newText;
var periodo = parseInt(newText);
document.getElementById("hiddenControl").value = periodo;

How can i call my method in Ajax? this is my html input:

 <input runat="server" id="txperiodo" class="cc1" type="text" placeholder="AAAA/MM" maxlength="7" onblur="frmt_Date()"/> 

Thank you and please tell me if im wrong.

4
  • Is it web forms application or mvc application? Where the fillList() method is defined? Commented Nov 20, 2019 at 18:04
  • Web Forms Application. Commented Nov 20, 2019 at 18:04
  • i think yes, but if i set my method as "static" i can't call my html elements. The elements: hiddenControl and lisybox. Commented Nov 20, 2019 at 18:16
  • It works. Thank you. Commented Nov 20, 2019 at 18:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.