IIF返回资源变量
本文关键字:变量 资源 返回 IIF | 更新日期: 2023-09-27 18:03:41
文字:
<%# IIf(Container.DataItem("OldAdress") = Container.DataItem("NewAdress"), "", "Adress")%>
我想返回一个资源变量,而不是硬编码"地址"。
通过使用GetGlobalResourceObject/GetLocalResource对象函数。从https://msdn.microsoft.com/en-us/library/ms227982 (v = vs.140) . aspx
c#:<%@ Page Language="C#" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text =
GetLocalResourceObject("Button1.Text").ToString();
Image1.ImageUrl =
(String)GetGlobalResourceObject(
"WebResourcesGlobal", "LogoUrl");
Image1.Visible = true;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click"
Text="Get Resources" />
<asp:Image ID="Image1" runat="server"
Visible="false" />
</div>
</form>
</body>
</html>
VB。净:
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Button1_Click( _
ByVal sender As Object, ByVal e As System.EventArgs)
Button1.Text = _
GetLocalResourceObject("Button1.Text").ToString()
Image1.ImageUrl = _
CType(GetGlobalResourceObject("WebResourcesGlobal", _
"LogoUrl"), String)
Image1.Visible = True
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click"
Text="Get Resources" />
<asp:Image ID="Image1" runat="server"
Visible="false" />
</div>
</form>
</body>
</html>