Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# .net change label text

Hello for I trying to use this code but for some reason it doesn't work. Really need help with this. The problem is that the label doesn't change name from "label" when I enter the site.

<asp:Label ID="Label1" runat="server" Text="label"></asp:Label>


<% 
    Label1.Text = "test";
    if (Request.QueryString["ID"] != null)
    {

        string test = Request.QueryString["ID"];
        Label1.Text = "Du har nu lånat filmen:" + test;
    }

     %>
like image 585
Morgan Avatar asked May 26 '10 20:05

Morgan


2 Answers

you should convert test type >>>> test.tostring();

change the last line to this :

Label1.Text = "Du har nu lånat filmen:" + test.tostring();
like image 60
ok.baby Avatar answered Oct 11 '22 15:10

ok.baby


Old question, but I had this issue as well, so after assigning the Text property, calling Refresh() will update the text.

Label1.Text = "Du har nu lånat filmen:" + test;
Refresh();
like image 39
Hovestar Avatar answered Oct 11 '22 13:10

Hovestar