如何將方法輸出分配給沒有代碼背後的文本框值?如何將方法的輸出分配給無背後代碼的文本框值
<%@ 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>
導致編譯錯誤。