CanMike
05-10-2006, 04:07 AM
<%@ Page Language="VB" debug="true"%>
<script runat="server">
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub page_load()
if IsPostBack then
lblout.text = txtWord1.text
call insertLineBreak(lblout.text, _
NumberOptions.SelectedItem.Value, _
WidthOptions.SelectedItem.Value)
lblout.text += txtWord2.text <- Doesn't this concatenate the strings
call insertLineBreak(lblout.text, _
NumberOptions.SelectedItem.Value, _
WidthOptions.SelectedItem.Value)
end if
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub insertLineBreak(textIn as String, NumLines as byte, Width as short)
dim LineCoutner as byte
for LineCoutner=1 to NumLines
lblout.text += "<br /><hr width='" & Width & "' align='left'>"
next
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
</script>
<html>
<head><title>SubRoutine with Parameters Example</title></head>
<body>
Enter two words and click on submit<br />
<form runat="server">
<asp:textbox id="txtWord1" runat="server" text="Default text 1"/>
<asp:textbox id="txtWord2" runat="server" text="Default text 2"/>
<asp:radiobuttonlist id="WidthOptions" runat="server">
<asp:listitem id="w100" value="100" runat="server" />
<asp:listitem id="w300" value="300" runat="server" />
<asp:listitem id="w600" value="600" runat="server" />
</asp:radiobuttonlist>
<asp:dropdownlist id="NumberOptions" runat="server">
<asp:listitem>1</asp:listitem>
<asp:listitem>2</asp:listitem>
<asp:listitem>3</asp:listitem>
</asp:dropdownlist>
<asp:button id="button1" runat="server" text="Button"></asp:button>
<br />
<br />
<asp:label id="lblout" runat="server" text="default output"></asp:label>
</form>
</body>
</html>
Notice this code. I'm teaching myself ASPX from 'Beginning ASP.NET 1.1 with VB.NET 2003" from Wrox publishing and this is one of their examples.
For this example lets assign the value to txtWord1 as blue, and txtWord2 as banana.
When you run this in your browser it displays each entered text on separate lines with line drawn underneath the texts. Fine. But shouldn't that line lblout.text += txtWord2 concatenate the string so that the next line of text displayed would be bluebanana. Yet when you run the code it's not.
What's up with that?
<script runat="server">
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub page_load()
if IsPostBack then
lblout.text = txtWord1.text
call insertLineBreak(lblout.text, _
NumberOptions.SelectedItem.Value, _
WidthOptions.SelectedItem.Value)
lblout.text += txtWord2.text <- Doesn't this concatenate the strings
call insertLineBreak(lblout.text, _
NumberOptions.SelectedItem.Value, _
WidthOptions.SelectedItem.Value)
end if
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sub insertLineBreak(textIn as String, NumLines as byte, Width as short)
dim LineCoutner as byte
for LineCoutner=1 to NumLines
lblout.text += "<br /><hr width='" & Width & "' align='left'>"
next
end sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
</script>
<html>
<head><title>SubRoutine with Parameters Example</title></head>
<body>
Enter two words and click on submit<br />
<form runat="server">
<asp:textbox id="txtWord1" runat="server" text="Default text 1"/>
<asp:textbox id="txtWord2" runat="server" text="Default text 2"/>
<asp:radiobuttonlist id="WidthOptions" runat="server">
<asp:listitem id="w100" value="100" runat="server" />
<asp:listitem id="w300" value="300" runat="server" />
<asp:listitem id="w600" value="600" runat="server" />
</asp:radiobuttonlist>
<asp:dropdownlist id="NumberOptions" runat="server">
<asp:listitem>1</asp:listitem>
<asp:listitem>2</asp:listitem>
<asp:listitem>3</asp:listitem>
</asp:dropdownlist>
<asp:button id="button1" runat="server" text="Button"></asp:button>
<br />
<br />
<asp:label id="lblout" runat="server" text="default output"></asp:label>
</form>
</body>
</html>
Notice this code. I'm teaching myself ASPX from 'Beginning ASP.NET 1.1 with VB.NET 2003" from Wrox publishing and this is one of their examples.
For this example lets assign the value to txtWord1 as blue, and txtWord2 as banana.
When you run this in your browser it displays each entered text on separate lines with line drawn underneath the texts. Fine. But shouldn't that line lblout.text += txtWord2 concatenate the string so that the next line of text displayed would be bluebanana. Yet when you run the code it's not.
What's up with that?