Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am working on a internet site which has all the best practices used in it. I have a simple task but want to make sure that i also use the best possible solution.

The requirement is that i have to output a text which contains a link on the webpart

so i have taken a literal

<asp:Literal ID="litVal" runat="server"></asp:Literal>

and in code behind string outVal = someFunction();//get val from list

value of outVal is (without quotes)

"some text here some text, some text here some text here"

Now, what i have to do is - to get the link on the part of the text after "comma"

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Not sure I'm clear on what the issue is but why are you not using HyperLink control instead? Within the code behind or in the ASCX code, you can set the value of the control easily.

Be aware of how the Visual Web Parts actually work:

1) The Web Part - this hosts the control and is how you can create web properties to pass to the control (this provides the SharePoint context to the control).

2) The Control - separate code behind but is effectively a .NET control running 'on top' of SharePoint. By default, it doesn't even have a reference to SP (this has to be added). However, the context is there so you can access SharePoint in the background.

Coding a Visual Control is the same as .NET; all the same controls are available. If you get it to work in a .NET site, you can cut/paste into a Visual Control.

David Sterling davidmsterling.blogspot.com www.sterling-consulting.com

share|improve this answer
1  
and to be complete (I don't understand the question either ;) ): To just get the string behind the comma, use outVal.Split(',').Last() in your code-behind. –  Dominik Dec 14 '12 at 19:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.