Ok here is my problem[or you can sat awkward question), I have a label I have created a link for it, working example below:
string strLinkBegin = "<a href='";
//string strLinkMid = "'>";
string strLinkMid = "' target='_blank'>";
string strLinkEnd = "</a>";
string strQuerystring = "";
strQuerystring = "somePage.aspx" + "?AMode=" + "Update" + "&someID=" + hdnsomeLink.Value;
lblFromDesc.Text = strLinkBegin + strQuerystring + strLinkMid + hdnFromDescText.Value + strLinkEnd;
Real question: can I write something similar to code you see below in a label and when user clicks it it executes? I know I can program through link button but was interested if its possible to do the same thing in a label.
someclass WTRadWindow = new someclass();
WTRadWindow.OpenUpdateForm(Page, hdnToDescLinkURL.Value, 350, 263);
The
Labelcontrol cannot contain HTML text, it is designed to display plain text.As discussed in another answer, the most appropriate solution would be to use the
HyperlinkControl.If it’s really important for you to generate the HTML as a string and then add it to the page you would need to use the
LiteralControl. If you just used that instead of a label your existing code should work just fine. I want to mention though that literal controls should be used sparingly, and that it really isn’t appropriate in this situation. So much of what makes ASP great is that you don’t need to create HTML as a string.