Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to assign a method's output to a textbox value without code behind
    primarykey
    data
    text
    <p>How do I assign a method's output to a textbox value without code behind?</p> <pre><code>&lt;%@ Page Language="VB" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;script runat="server"&gt; 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 &lt;/script&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;Test Page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;%=TextFromString%&gt; &lt;br /&gt; &lt;asp:TextBox ID="TextBox1" runat="server" Text="&lt;%# TextFromString %&gt;"&gt;&lt;/asp:TextBox&gt; &lt;br /&gt; &lt;%=TextFromMethod%&gt; &lt;br /&gt; &lt;asp:TextBox ID="TextBox2" runat="server" Text="&lt;%# TextFromMethod %&gt;"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me.</p> <p>It's also confusing to me why</p> <pre><code>&lt;asp:Label runat="server" ID="label1"&gt;&lt;%=TextFromString%&gt;&lt;/asp:Label&gt; </code></pre> <p>and</p> <pre><code>&lt;asp:TextBox ID="TextBox3" runat="server"&gt;Hello&lt;/asp:TextBox&gt; </code></pre> <p>works but </p> <pre><code>&lt;asp:TextBox ID="TextBox4" runat="server"&gt;&lt;%=TextFromString%&gt;&lt;/asp:TextBox&gt; </code></pre> <p>causes a compilation error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload