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
Have you tried running the code in the Page_Load() method?
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "test";
if (Request.QueryString["ID"] != null)
{
string test = Request.QueryString["ID"];
Label1.Text = "Du har nu lånat filmen:" + test;
}
}
Label label1 = new System.Windows.Forms.Label
//label1.Text = "test";
if (Request.QueryString["ID"] != null)
{
string test = Request.QueryString["ID"];
label1.Text = "Du har nu lånat filmen:" + test;
}
else
{
string test = Request.QueryString["ID"];
label1.Text = "test";
}
This should make it
you should convert test type >>>> test.tostring();
change the last line to this :
Label1.Text = "Du har nu lånat filmen:" + test.tostring();
When I had this problem I could see only a part of my text and this is the solution for that:
Be sure to set the AutoSize property to true.
output.AutoSize = true;
If I understand correctly you may be experiencing the problem because in order to be able to set the labels "text" property you actually have to use the "content" property.
so instead of:
Label output = null;
output = Label1;
output.Text = "hello";
try:
Label output = null;
output = Label1;
output.Content = "hello";
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();