如何在没有代码隐藏的情况下将方法的输出分配给文本框值?
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public TextFromString As String = "test text test text"
Public TextFromMethod As String = RepeatChar("S", 50) SubSonic.Sugar.Web.GenerateLoremIpsum(400, "w")
Public Function RepeatChar(ByVal Input As String, ByVal Count As Integer)
Return New String(Input, Count)
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=TextFromString%>
<br />
<asp:TextBox ID="TextBox1" runat="server" Text="<%# TextFromString %>"></asp:TextBox>
<br />
<%=TextFromMethod%>
<br />
<asp:TextBox ID="TextBox2" runat="server" Text="<%# TextFromMethod %>"></asp:TextBox>
</div>
</form>
</body>
</html>
这主要是为了让设计师可以在aspx页面中使用它。对我来说,将变量值推入文本框似乎是一件简单的事情。
我也很困惑为什么
<asp:Label runat="server" ID="label1"><%=TextFromString%></asp:Label>
和
<asp:TextBox ID="TextBox3" runat="server">Hello</asp:TextBox>
有效,但是
<asp:TextBox ID="TextBox4" runat="server"><%=TextFromString%></asp:TextBox>
导致编译错误。