StringBuilder and href

I cant get this stringbulder with href working. I want a hyperlink but it actually displays the contacted string...
StringBuilder sb = new StringBuilder();

        sb.Append("<a href = ");//'~/~/Job/JobOpening.aspx?jobId=' + Request.QueryString[_idQueryStringKey] > CompanyName </a>");
        sb.Append("'~/~/Job/JobOpening.aspx?jobId='");
        sb.Append(Request.QueryString[_idQueryStringKey]);
        sb.Append(">");
        sb.Append("Job Opening");
        sb.Append("</a>");


        txtBody.Text = sb.ToString();

//**** displays it as this
<a href = '~/~/Job/JobOpening.aspx?jobId='22>Job Opening</a>

Open in new window

LVL 8
CamilliaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
>txtBody.Text = sb.ToString();

normal. your textbox won't automatically display a href from html code.
you need to change the html, for example of a label's innerhtml, to that html ...
0
CamilliaAuthor Commented:
trying to find an example, i even tried HTMLDecode. Here it says to use Literal but literal is not multi line:

http://forums.asp.net/t/1261858.aspx

0
NazoUKCommented:
Why not just create a hyperlink control, set the text property to "CompanyName" then set the NavigateUrl property from the code behind?

myHyperlink.NavigateUrl = string.Fomat("{0}{1}", "~/Job/JobOpening.aspx?jobId=", Request.QueryString[_idQueryStringKey]);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Gagan_JauraCommented:
The code written should be rendered to HTML also. Use Documnet.write().
StringBuilder sb = new StringBuilder();
       sb.Append("<a href = ");
        sb.Append("'~/~/Job/JobOpening.aspx?jobId='");
        sb.Append(Request.QueryString[_idQueryStringKey]);
        sb.Append(">");
        sb.Append("Job Opening");
        sb.Append("</a>");
Document.write(sb.toString())
0
CamilliaAuthor Commented:
let me try, i think i can also use a Literal. I have a textbox and i need to display the URL in that text box..but let me try...
0
CamilliaAuthor Commented:
No, the issue is that i have a textbox. This textbox is supposed to be body of an email being sent. So first, user sees this textbox, with this link in it, then i click submit and send the email with that link in it...It's 'send this job to a friend" page..with a TO, From, Subject Line and Body of the email/

I know what i have doesnt work and the reason for it, I know i can use a rich textbox (like Telerik) but too much..i know i can even use a Literal but how do i display it on the textbox..

will play around with it more and see what i come up with...
0
CamilliaAuthor Commented:
Or, if i use a hyperlink, somehow with CSS, i need to have a box around it..trying a label to make it look like a texbox but it looks like a hyperlink

<asp:Label runat="server" ID="test" Text="<a href='some link'> testing</a>" ></asp:Label>
0
CamilliaAuthor Commented:
ah, maybe the hyperlink or label inside a panel, then make the panel look like a textbox, with CSS. Will try that..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.