String concatenation (C#)
<%@ Page Language="C#" %>
<script runat="server">
void page_Load()
{
string str;
str = "Spring" + "Sale";
lblOut1.Text = str;
string str2;
DateTime datSaleSpring = Convert.ToDateTime("3/3/2005");
str2 = "Spring" + " " + "Sale begins " + Convert.ToString(datSaleSpring);
lblOut2.Text = str2;
lblSaleNote3.Text = "Spring" + " " + "Sale begins " + Convert.ToString(datSaleSpring);
string str4;
str4 = "Sale starts on 3/1/2005";
str4 = str4 + " and ends on " + txtSaleEnd.Text;
lblSaleNote4.Text = str4;
string str5;
str5 = "Sale starts on 3/1/2005 and ends on ";
str5 += txtSaleEnd.Text;
lblSaleNote5.Text = str5;
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<hr>Example 1<br>
<asp:Label runat="server" ID="lblOut1"/><br/>
<hr>Example 2<br>
<asp:Label runat="server" ID="lblOut2"/><br/>
<hr>Example 3<br>
<asp:Label runat="server" ID="lblSaleNote3"/><br/>
<hr>Example 4<br>
Sale End Date = <asp:TextBox runat="server" ID="txtSaleEnd"/>
<asp:Button runat="server" Text="Button"></asp:Button><br/>
<asp:Label runat="server" ID="lblSaleNote4"/><br/>
<hr>Example 5<br>
<asp:Label runat="server" ID="lblSaleNote5"/><br/>
</form>
</body>
</html>
Related examples in the same category