使用ajax ModalPopupExtender ID和javascript显示modalpopup [英] showing modalpopup using ajax ModalPopupExtender ID and javascript

查看:46
本文介绍了使用ajax ModalPopupExtender ID和javascript显示modalpopup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,我希望当我单击该按钮时,数据应该保存在数据库中,同时还应弹出一个模式弹出窗口.
应该显示customerid.我已将代码写为

i have a button ,i want that when i click on that button the data should be saved in the database as well as at the same time a modal popup
should display the customerid .i have written the code as

<asp:button id="save1" runat="server" onclick="Button4_Click" style=""z-index:" mode="hold" xmlns:asp="#unknown" />           left: 740px; position: absolute; top: 304px" Text="save"/>

<asp:panel id="panel" runat="server" xmlns:asp="#unknown"></asp:panel>

                <ajaxtoolkit:modalpopupextender id="MPE" runat="server" targetcontrolid="save1" xmlns:ajaxtoolkit="#unknown">
                PopupControlID="panel" DropShadow="true"
                BackgroundCssClass="modalBackground/>
</ajaxtoolkit:modalpopupextender>


protected void Button4_Click(object sender, EventArgs e)
   {
       string id = TextBox1.Text;
       string name = TextBox2.Text;
       string cn = "Data Source=hcl;Initial Catalog=mydata;Integrated Security=True";
       SqlConnection con = new SqlConnection(cn);
       SqlCommand cmd = new SqlCommand("insert into customer values (@id,@name)", con);
       con.Open();
       cmd.CommandType = CommandType.Text;
       cmd.Parameters.Add("@id", id);
       cmd.Parameters.Add("@name",name);

       cmd.ExecuteNonQuery();

       con.Close();
       CUSTID.Text = id.ToString();
       MPE.Show();
}



但它没有发生.即使我在MPE.Show()注释弹出窗口时显示行
即将来临.我不了解正在发生的事情,请帮助我使用ajax和普通javascript编写代码.



but it is not happening.even if i comment the MPE.Show() line a popup
is coming.i m not understanding what is happening plz help i want code using ajax as well as normal javascript.

推荐答案

如果您阅读了ModalPopup [
If you read the documentation for ModalPopup[^] you will understand what is happening.
TargetControlID - The ID of the element that activates the modal popup.

If you look at the documentation you will see a sample for activating the ModalPopup from server-side code.


因此您的弹出窗口正在显示,但C#代码似乎未在执行?也许尝试删除 targetcontrolid ="save1" .我猜想模态弹出窗口正在拦截click事件,因此可以防止回发(因此您的C#代码未运行).如果删除了该代码,但保留了 MPE.Show(),则应在C#运行后弹出模式.
So your popup is showing, but the C# code doesn''t appear to be executing? Perhaps try removing targetcontrolid="save1". I am guessing that the modal popup is intercepting the click event and so is prevent a postback (so your C# code isn''t running). If you remove that, but keep the MPE.Show(), then the modal should popup after your C# runs.


这篇关于使用ajax ModalPopupExtender ID和javascript显示modalpopup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆