通过将url作为参数传递来打开SharePoint Popup [英] Open SharePoint Popup by passing url as parameter
问题描述
以下代码运行正常
在.aspx页面中
======================================
The Following code is working perfectly
in .aspx page
========================================
<script type="text/javascript">
function openDialog()
{
var ur="http://google.com"
var options =
{
url: ur,
width: 800,
height: 600,
title: "Event Details",
};
SP.UI.ModalDialog.showModalDialog(options);
}
</script>
<asp:Literal ID="htm" runat="server"></asp:Literal>
在aspx.cs页面中,我正在按以下方式调用函数
================================================== =
in aspx.cs page I am calling the function as follows
===================================================
htm.Text = "<a href='#', onclick='openDialog()'>"
上面的代码正常工作
但是,如果我通过"http://google.com"作为参数(如下所示),则无法正常运行
在.aspx页面中
======================================
The above code is working properly
But If I pass "http://google.com" as parameter (as below) it is not working
in .aspx page
========================================
<script type="text/javascript">
function openDialog(ur)
{
var options =
{
url: ur,
width: 800,
height: 600,
title: "Event Details",
};
SP.UI.ModalDialog.showModalDialog(options);
}
</script>
<asp:Literal ID="htm" runat="server"></asp:Literal>
在aspx.cs页面中,我正在按以下方式调用函数
================================================== =
in aspx.cs page I am calling the function as follows
===================================================
string ur="http://Google.com"
htm.Text = "<a href='#', onclick='openDialog("+ur+")'>"
谁能纠正
Can any one correct the
推荐答案
我认为您没有正确地转义文本字符串.尝试以下方法:
I don''t think you''re escaping your text string correctly. Try this instead:
string ur="http://Google.com";
htm.Text = string.Format(@"<a href="#" önclick="openDialog('{0}');">{0}</a>", ur);
但是,有一个问题,为什么您要使用文字在页面上显示超链接?
怎么了?
A question though, why on earth are you using a literal to display a hyperlink on a page?
What''s wrong with:
<asp:HyperLink ID="hyperLink" runat="server" NavigateUrl="#" />
并且:
And:
string ur="http://Google.com";
hyperLink.Text = ur;
hyperLink.OnClientClick = string.Format("openDialog('{0}');", ur);
?
?
这篇关于通过将url作为参数传递来打开SharePoint Popup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!