2014-03-01 2 views
0

asp 버튼이있는 팝업 창이있는 asp.Net에 웹 사이트가 있습니다. 내 문제는 버튼 클릭 이벤트가 팝업에서 발생하지 않는다는 것입니다. imagebutton1이 클릭되면 내 팝이 열립니다. 나는 또한 타이머 틱을 사용하고있다. 나는 그것에 완전히 갇혀있다. 다음과 같이 내 코드는 다음과 같습니다 -팝업창에서 버튼 클릭 이벤트가 발생하지 않습니다.

<div> 
    <script type="text/javascript"> 
     function buttonClicked() { 
     var textBox = $get("TextBox1"); 
     textBox.scrollTop = textBox.scrollHeight; 
     } 

     </script> 

     <asp:UpdatePanel ID="ChatUpdatePanel" runat="server" UpdateMode="Always"> 
           <ContentTemplate> 

     <div id="second1" runat="server" style="width:570px;height:100px;background-color:#e5f7f6;border:solid 2px #35b8b3;position:absolute;margin-left:5px;margin-top:5px;border-radius:5px;"> 
     <span style="color:Blue;font-weight:bold;margin-left:180px;margin-top:20px;">Ringing Expert...Please Wait</span> 

</div>     
       <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" ReadOnly="True" 
            width="100%" style="resize:none;" Height="200px" AutoPostBack="False" 
        MaintainScrollPositionOnPostBack="True" > 
        </asp:TextBox> 

      </ContentTemplate> 
      <Triggers> 
       <%--<asp:AsyncPostBackTrigger ControlID="SendButton" EventName="Click" />--%> 
       <asp:AsyncPostBackTrigger ControlID="ChatTextTimer" EventName="Tick" /> 
      </Triggers> 
     </asp:UpdatePanel> 
       <asp:Timer runat="server" ID="ChatTextTimer" Interval="100" 
        ontick="ChatTextTimer_Tick" /> 

        <asp:TextBox ID="NewMessageTextBox" DefaultButton="SendButton" Columns="50" runat="server" Height="25px" 
      Width="80%" style="margin-left: 0px;margin-top:5px;" Font-Size="Medium" /> 
        <asp:Button ID="SendButton" Text="Send" runat="server" OnClick="SendButton_Click" Height="25px" style="margin-left:50px;" /> 
        <a href="#" style="text-decoration:line;">Report Abuse</a> 
        <br /> 
        <div style="width:100%;margin-top:10px;"> 
         <asp:Image ID="Image3" runat="server" Width="70px" Height="50px" /> 
          <div style="width:80%;height:50px;float:right;margin-right:30px;"> 
            Status:<br /> 
            <span style="color:Blue;font-weight:bold;font-size:large;">Not Charging</span> 
            <span style="float:right;font-weight:bold;font-size:medium;color:Blue;">$ <asp:Label ID="Label12" runat="server" style="font-weight:bold;font-size:medium;color:Blue;" Text="Label"></asp:Label>/Minute</span> 
          </div> 
        </div> 

내 백엔드 코드는 다음과 같다 : -

  protected void ImageButton1_Click(object sender, ImageClickEventArgs e) 
{ 
    second1.Visible = false; 
    if (Session["User"] != "User") 
    { 
     Response.Redirect("signin.aspx"); 
    } 
    else 
    { 
     if (Int32.Parse(Label13.Text) < 20) 
     { 
      Response.Redirect("Payment.aspx"); 
     } 
     else 
     { 
      if(Int32.Parse(Label14.Text)==0) 
      { 
       Response.Redirect("ExpertMail.aspx?id="+Int32.Parse(Request.QueryString["id"])); 
      } 
      else 
      { 
       string str1 = Label1.Text; 
       string str = "<script type='text/javascript'>$(function(){ $('#modal_dialog').dialog({title: 'Chat with Expert', modal: true }); return false; });</script>"; 
       Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false); 
       Image3.ImageUrl = Label8.Text; 

      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LPSConnection"].ConnectionString.ToString()); 
      con.Open(); 
      SqlDataReader rd = new SqlCommand("Select Booked from ExpertChat where id=" + Int32.Parse(Request.QueryString["id"]), con).ExecuteReader(); 
      rd.Read(); 
      int y = Int32.Parse(rd["Booked"].ToString()); 
      rd.Close(); 
      if (y == 0) 
      { 

       SqlDataReader mRead1, mRead3,mRead4; 
       mRead1 = new SqlCommand("insert into chat (ExpertName,UserName,rate) Values ('" + Label1.Text + "','" + Session["SName"] + "','" + Label5.Text + "')", con).ExecuteReader(); 
       mRead1.Close(); 
       mRead3 = new SqlCommand("Update ExpertChat Set Booked=1 where SName='" + Label1.Text + "'", con).ExecuteReader(); 
       mRead3.Close(); 
       second1.Visible = true; 
       con.Close(); 

      } 
      con.Close(); 

      } 
     } 
    } 

} 
public void wait(int x) 
{ 

} 
protected void ChatTextTimer_Tick(object sender, EventArgs e) 
{ 
    if (second1.Visible) 
    { 
     SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LPSConnection"].ConnectionString.ToString()); 
     con.Open(); 
     SqlDataReader mRead4 = new SqlCommand("Select top 1 id from Chat where ExpertName='" + Label1.Text + "' order by id desc", con).ExecuteReader(); 
     mRead4.Read(); 
     int z = Int32.Parse(mRead4["id"].ToString()); 
     mRead4.Close(); 

     SqlDataReader rd = new SqlCommand("Select IsApproved from Chat where id=" + z, con).ExecuteReader(); 
     rd.Read(); 
     string str = (rd["IsApproved"].ToString()); 
     rd.Close(); 
     if (str == "Approved") 
     { 
      second1.Visible = false; 

     } 
     else if (str == "canceled") 
     { 

     } 
     else 
     { 
      con.Close(); 

     } 

    } 
    else 
    { 
     int x1 = 0; 
     SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LPSConnection"].ConnectionString.ToString()); 
     con.Open(); 
     SqlDataReader rd; 
     rd = new SqlCommand("Select UserInitial,Updated from Chat where id =" + Int32.Parse(Request.QueryString["id"].ToString()), con).ExecuteReader(); 
     rd.Read(); 
     string str; 
     int i; 
     str = rd["UserInitial"].ToString(); 
     i = Int32.Parse(rd["Updated"].ToString()); 
     rd.Close(); 
     if (i == 1) 
     { 
      x1 = x1 + 1; 
      TextBox1.Text = TextBox1.Text + Environment.NewLine + str; 
      SqlCommand 
      cmd = new SqlCommand("Update Chat set Updated=0 where id=" + Int32.Parse(Request.QueryString["id"].ToString()), con); 
      cmd.ExecuteNonQuery(); 

     } 
     ScriptManager.RegisterStartupScript(this, this.GetType(), "TextBox1slide", "buttonClicked();", true); 
     con.Close(); 
    } 
} 
protected void SendButton_Click(object sender, EventArgs e) 
{ 
    //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["LPSConnection"].ConnectionString.ToString()); 
    //con.Open(); 
    string messageMask = "{0} : {2}"; 
    string message = string.Format(messageMask, Session["SName"].ToString(), DateTime.Now.ToShortTimeString(), NewMessageTextBox.Text); 
    TextBox1.Text = TextBox1.Text + Environment.NewLine + message; 
    //SqlCommand cmd, cmd1; 
    //cmd = new SqlCommand("Update Chat set Data='" + message + "' where id=" + Int32.Parse(Request.QueryString["id"].ToString()), con); 
    //cmd.ExecuteNonQuery(); 
    //cmd1 = new SqlCommand("Update Chat set Updated1=1 where id=" + Int32.Parse(Request.QueryString["id"].ToString()), con); 
    //cmd1.ExecuteNonQuery(); 
    NewMessageTextBox.Text = ""; 
    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myScript", "document.getElementById('" + NewMessageTextBox.ClientID + "').value = '';", true); 
    ScriptManager.RegisterStartupScript(this, this.GetType(), "TextBox1slide", "buttonClicked();", true); 



} 
+0

어떤 버튼의 이벤트가 실행되지 않습니까? 그리고 자바 스크립트 함수'buttonClicked'가 호출되지 않았습니까? 아니면 asp.net 코드 숨김'button_Click' 이벤트를 의미합니까? –

+0

버튼 ID는 SendButton이며이 버튼은 백엔드 코드에서 이벤트를 발생시켜야합니다. 이것은 실제로 서버 측 코드입니다. – yash

답변

1

내가 그것을 해결했다. 바보 같은 실수였습니다. 버튼의 SubMitBehaviour 속성을 false로 설정하십시오.

관련 문제