【发布时间】:2016-05-18 06:25:40
【问题描述】:
我有一个调用引导模式弹出窗口的 Js 函数。我在单击按钮时从后面的代码中调用此 Js 函数。问题是当我单击按钮时它显示模式弹出窗口,但是当我导航到另一个页面时(当我单击另一个按钮时,它导航到谷歌文档阅读器)并返回主页,它又是无需单击任何按钮即可加载弹出窗口。谁能帮我解决这个问题。
JS函数
<head>
<script type="text/javascript">
function showModal() {
$('#viewOc').modal();
};
</script>
</head>
模态弹出代码
<div class="modal fade" id="viewOc" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4>TRIAL</h4>
</div>
<div class="modal-body">
LOREM IPSUM
</div>
<div class="modal-footer">
<a class="btn btn-primary" data-dismiss="modal">
Close
</a>
</div>
</div>
</div>
</div>
后面的代码
protected void LinkButton1_Click(object sender, CommandEventArgs e)
{
//some operations here
string script = "window.onload = function() { showModal(); };";
ClientScript.RegisterStartupScript(this.GetType(), "modalShow", script, true);
}
HTML代码
<asp:LinkButton ID="LinkButton1" runat="server" Text="Click Here" CausesValidation="false" commandArgument='<%#Eval("value")%>' OnCommand="LinkButton1_Click"/>
Google Docs 按钮点击事件
protected void btnView_View(object sender, CommandEventArgs e)
{
//not sure if the below code is correct or wrong. But as of now im using this in my application. Didnt try it on server yet.
string path = e.CommandArgument.ToString();
Response.Redirect("http://docs.google.com/viewer?url=" + Server.UrlEncode(path),true);
}
页面加载
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
IndexDocuments();
}
}
P.S:我知道类似的问题,但在 SO 中提出了不同的问题。由于我没有足够的声誉来评论这个问题,我不得不发表一个新帖子。
【问题讨论】:
标签: javascript c# html asp.net twitter-bootstrap