在提交按钮后弹出我的引导程序模式时遇到问题。
需要发生的事情如下:
第1步和第2步工作正常,但第3步无法正常工作。下面是我的代码段。
<asp:Button ID="addcomputerassetbutton" CssClass="btn btn-primary"
OnClick="AddcomputerassetBtn_Click" runat="server" Text="Add Computer Asset" />
<!-- Modal -->
<div class="modal fade" id="ModalCenter" tabindex="-1" role="dialog" aria-labelledby="Assetadded" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<asp:ScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="upModal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle"><asp:Label ID="lblModalTitle" runat="server" Text=""></asp:Label></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<asp:Label ID ="assetadded" runat="server"></asp:Label>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="javascript:window.location='http://assetdb.local/asset?action=addcomputer'">OK</button>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
文件后码
protected void AddcomputerassetBtn_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AssetDBConnection"].ConnectionString);
SqlCommand cmd = new SqlCommand("usp_addnewasset", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("assetNumber", inputassettag.Text);
cmd.Parameters.AddWithValue("assetcatid", categoryid);
cmd.Parameters.AddWithValue("assetname", inputassetname.Text);
cmd.Parameters.AddWithValue("assetmodel", inputmodelnumber.Text);
cmd.Parameters.AddWithValue("assetmanufacture", inputassetmanufacture.Text);
cmd.Parameters.AddWithValue("assetservicetag", inputassetservicetag.Text);
cmd.Parameters.AddWithValue("assetstatus", inputassetstatus.Text);
cmd.Parameters.AddWithValue("assetcompany", inputassetcompany.Text);
cmd.Parameters.AddWithValue("assetoffice", inputassetoffice.Text);
cmd.Parameters.AddWithValue("assetdepartment", inputassetdepartment.Text);
cmd.Parameters.AddWithValue("assetuser", inputassetuser.Text);
cmd.Parameters.AddWithValue("assetcost", inputassetcost.Text);
cmd.Parameters.AddWithValue("assetram", inputassetram.Text);
cmd.Parameters.AddWithValue("assetcpu", inputassetcpu.Text);
cmd.Parameters.AddWithValue("assetdiskdrive", inputassethdd.Text);
cmd.Parameters.AddWithValue("assetlocaladminuser", inputassetadminusername.Text);
cmd.Parameters.AddWithValue("assetlocaladminpassword", inputassetlocaladminpassword.Text);
//cmd.Parameters.AddWithValue("catdescription", inputimei.Text);
//cmd.Parameters.AddWithValue("catname", inputassetmobilenumber.Text);
con.Open();
int k = cmd.ExecuteNonQuery();
if (k != 0)
{
lblModalTitle.Text = "Asset Added OK";
assetadded.Text = "The Asset has been added to the Database";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalCenter", "$('#ModalCenter').modal();", true);
upModal.Update();
}
else
{
lblModalTitle.Text = "Asset Not added OK";
assetadded.Text = "There was an error adding the asset";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalCenter", "$('#ModalCenter').modal();", true);
upModal.Update();
}
con.Close();
}
感谢您的帮助
答案 0 :(得分:0)
首先,您可以通过单击一个简单的按钮来检查是否可以打开模态
如果成功,那么您可以通过
这样的参数开始AddRecord.aspx?added=true
继续
$(document).ready(function(){
//Read the parameter values and if true show the dialog using
$('#ModalCenter').modal();
});