我想点击dialog box
内的button
打开gridview
但是,无论何时我点击按钮,页面都会刷新。我尝试过UseSubmitBehavior=false
,但我的页面仍在回传。
这是我的button
<asp:Button ID="FlAttachParty" runat="server" Width="150px" Height="25px" Text="Add Attachment" OnClick="FlAttachParty_Click" CausesValidation="false" />
请建议如何实现这个目标
更新
服务器端代码
protected void FlAttachParty_Click(object sender, EventArgs e)
{
if (strMode == "A")
{
if (HidAttachParty.Value == "")
{
ObjPriCon.Open();
OracleCommand objpricmd = new OracleCommand("select xxcus.xxacl_pn_party_info_SEQ.nextval from dual", ObjPriCon);
HidAttachParty.Value = Convert.ToString(objpricmd.ExecuteOracleScalar());
ObjPriCon.Close();
}
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "AttachmentCallParty(" + HidAttachParty.Value + ");", true);
}
else
{
if (HidAttachParty.Value == "")
{
ObjPriCon.Open();
OracleCommand ObjPriCmd = new OracleCommand("select xxcus.xxacl_pn_party_info_SEQ.nextval from dual", ObjPriCon);
HidAttachParty.Value = Convert.ToString(ObjPriCmd.ExecuteOracleScalar());
ObjPriCon.Close();
}
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "AttachmentCallParty(" + HidAttachParty.Value + ");", true);
}
}
答案 0 :(得分:2)
Asp:Button
是一个服务器控件,用于向服务器发送请求并获取响应需要页面刷新。
无论您是否绑定了OnClick事件,控件都会将标记呈现为。这意味着您的表单将在点击时提交给服务器,除非您使用javascript停止它。
一种解决方案是使用Ajax
来电。
另一个解决方案是使用HTML
按钮并绑定click
事件处理程序。
<input type="button" id="BtnGo" class="button" value="Go" runat="server" onclick="funShortcuts()" style="height: 21px; width: 40px;" />
问题在于HidAttachID
。
所以你可以通过以下方式到达这里:
function funShortcuts() {
var str_mkey = "";
var MkeyVal = '<%= Request.QueryString["key"] %>';
if (MkeyVal == "10") {
var r1 = confirm('Do you want to open the attachment form ? ');
if (MkeyVal > 0) {
if (r1 == true) {
str_mkey = "'" + MkeyVal + "'";
}
else {
str_mkey = "'" + MkeyVal + "'";
}
var returnPara = window.showModalDialog("../PreSales/Transactions/FrmCrm_File_Attachment.aspx?Entity='XXACL_PN_PARTY_INFO','XXACL_PN_EXPENSE_INFO','XXACL_PN_VIEW_DATA_INFO'&mkey=" + MkeyVal + "&User_Attach=N&userid=<%=Request.QueryString.Get("userid")%>", null, 'unadorned:yes;resizable:1;dialogWidth:800px;dialogHeight:350px');
document.getElementById('HidCefMkey').value = MkeyVal;
}
else {
alert("Kindly save the form first..!!");
}
}
}