i have to labels on page load. one comes from a query string and one is coded onto the page. as follows
<script runat="server" language="C#">
protected void Page_Load(object sender, EventArgs e)
{
lblMessage.Text = Request.QueryString["message"];
lblcard.Text = "Transaction made successfully!";
}
</script>
how do i check if lblmessage has a text then it should only display that label and hide the lblcard text,if lblmessage doesnt have a text then it should show the "transaction made " text
You would use the String.IsNullOrEmpty
method documented here.
Your code would look something like this:
<script runat="server" language="C#">
protected void Page_Load(object sender, EventArgs e)
{
lblMessage.Text = Request.QueryString["message"];
if (String.IsNullOrEmpty(lblMessage.Text) {
lblcard.Text = "Transaction made successfully!";
}
}
</script>