CSS打破与自动回发OnSelectedIndexChanged

时间:2018-09-18 21:33:58

标签: javascript jquery asp.net

我被困在找不到合适答案的情况下,我有一个下拉列表,其中包含OnSelectedIndexChanged事件和AutoPost返回,位于更新面板中,当页面加载时会加载CSS,但会显示选定的更改事件CSS中断。另外,我在下拉列表中使用的是select2.js,这里是CSS中断前后的屏幕截图,请提前指导我如何完成此操作。 enter image description here enter image description here

这是我的下拉菜单和Onchange事件的代码

  <div class="form-group">
                    <label>POS Device Serial No</label><asp:Label 
       ID="lblSerialNoError" runat="server" Text=" (Invalid SerialNo)" 
    Visible="false"></asp:Label>
                  <asp:RequiredFieldValidator ID="SerialRequired" 
   runat="server" ControlToValidate="ddlPosSerialNo" InitialValue="" 
    ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
              <asp:ListBox ID="ddlPosSerialNo" runat="server" class="form- 
    control select2 " TabIndex="1" AutoPostBack="true" 
    OnSelectedIndexChanged="ddlPosSerialNo_SelectedIndexChanged"> 
    </asp:ListBox>

                </div>

    protected void ddlPosSerialNo_SelectedIndexChanged(object sender, 
    EventArgs e)
   {
    cRepairMaintanance obj = new cRepairMaintanance();
    DataTable dt = new DataTable();
    obj.PosSerialNo = ddlPosSerialNo.SelectedValue.ToString();
    dt = obj.ShowDetails();




    if (dt.Rows.Count > 0)
    {

        lblAcquirerName.Text = dt.Rows[0]["acquirerName"].ToString();
        lbldeployed.Text = dt.Rows[0]["merchantName"].ToString();
        lblmake.Text = dt.Rows[0]["makeName"].ToString();
        lblmodel.Text = dt.Rows[0]["modelName"].ToString();
        lblsim1.Text = dt.Rows[0]["sim1"].ToString();
        lblsim2.Text = dt.Rows[0]["sim2"].ToString();
        //lbldate.Text = DateTime.Now.ToString("dd-MMM-yy");
        lblSerialNoError.Visible = false;
    }
    else
    {
        lblAcquirerName.Text = string.Empty;
        lbldeployed.Text = string.Empty;
        lblmake.Text = string.Empty;
        lblmodel.Text = string.Empty;
        lblsim1.Text = string.Empty;
        lblsim2.Text = string.Empty;


        lblSerialNoError.Visible = true;
    }




}

0 个答案:

没有答案