使用 ASP.NET MVC3 的 Lync/Communicator/Sharepoint 状态控制
我目前正在将我们的业务网站从 ASP.NET WebForms 转换为 ASP.NET MVC3。我目前正在尝试为我的用户添加一个存在指示器,就像我们使用 WebForms 所做的那样。在 WebForms 中,我们使用了一个名为 NameControl.js
的文件(从 Microsoft 获取),其网站代码如下:
<ItemTemplate>
<span class="presence">
<asp:Image Style="" ID="PresenceImage" runat="server" ImageUrl="~/Common/Images/Shady/Presence/presence_16-unknown.gif" />
</span>
</ItemTemplate>
以及背后的代码:
private void SetPresence(GridViewRow row, int PRESENCE_COL, string sip)
{
Image presenceImage = row.FindControl("PresenceImage") as Image;
if (string.IsNullOrEmpty(sip))
presenceImage.Visible = false;
else
{
presenceImage.Attributes.Add("onload", "PresenceControl('" + sip + "');");
}
}
而且,这工作正常。那么,回到原来的问题。目前,我正在使用 WebGrid 列出我的用户,这是我的视图中的状态代码(在 WebGrid 内):
grid.Column("Sip", header: "", format: @<text><span class="presence"><img id="@item.ObjectGuid" src="@Url.Content("~/Content/Images/Shady/Presence/presence_16-unknown.gif")" onload="PresenceControl("@item.Sip")" alt="" /></span></text>),
当前发生的事情很简单,没什么。转义引号没有任何作用,仍然将它们排除在外。当我尝试使用 '@item.Sip'
而不是 "@item.Sip"
时,我收到一条错误消息:
Microsoft JScript 运行时错误:“PresenceControl”未定义
我不知道该怎么办。有人有什么想法吗?
好的,我发现问题了。 Microsoft 提供的 JavaScript 存在语法错误,导致 JavaScript 中断且无法正确加载。我使用 IE9 中的网络工具()观察控制台输出偶然发现了它。无论如何,现在已经修复了!
I'm currently converting our business site from ASP.NET WebForms to ASP.NET MVC3. I'm currently trying to include a presence indicator for my users, in the same way we did using WebForms. In WebForms we used a file called NameControl.js
(got it from Microsoft) with the site's code as such:
<ItemTemplate>
<span class="presence">
<asp:Image Style="" ID="PresenceImage" runat="server" ImageUrl="~/Common/Images/Shady/Presence/presence_16-unknown.gif" />
</span>
</ItemTemplate>
And the code behind:
private void SetPresence(GridViewRow row, int PRESENCE_COL, string sip)
{
Image presenceImage = row.FindControl("PresenceImage") as Image;
if (string.IsNullOrEmpty(sip))
presenceImage.Visible = false;
else
{
presenceImage.Attributes.Add("onload", "PresenceControl('" + sip + "');");
}
}
And, this is working fine. So, back to the original question. Currently i'm listing my users using WebGrid, and here is my presence code from my view (inside the WebGrid):
grid.Column("Sip", header: "", format: @<text><span class="presence"><img id="@item.ObjectGuid" src="@Url.Content("~/Content/Images/Shady/Presence/presence_16-unknown.gif")" onload="PresenceControl("@item.Sip")" alt="" /></span></text>),
What currently happens is simple, it's nothing. Escaping the quotes does nothing, leaving them out just the same. When I try using '@item.Sip'
instead of "@item.Sip"
, I get an error stating:
Microsoft JScript runtime error: 'PresenceControl' is undefined
I'm at a loss on what to do. Does anyone have any ideas?
OK, I found the problem. The Javascript delivered from Microsoft had a syntax error that made the javascript break and not load properly. I stumbled upon it using the web tools in IE9 () watching the console output. Anyway, it's fixed now!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论