how to send href as string to aspx page

radcoders
radcoders used Ask the Experts™
on
i want to send the following html to be embedded in string body, so if user is owner of post they can edit post, and if owner I want to embed this link but having problems with " don't know how to handle:

<a href="#" onclick="openEditPostWindow('<%# DataBinder.Eval(Container.DataItem, "ID") %>'); return false;"></a>
StringBuilder sb = new StringBuilder();
 
        sb.AppendLine("<b>Posted On:</b> " + postedON + "<br />");
        if (userID == userid)
        {
          sb.AppendLine(
<a href="#" onclick="openEditPostWindow('<%# DataBinder.Eval(Container.DataItem, "ID") %>'); return false;"></a>
 
             );  
        }
        else
            sb.AppendLine("<b>Posted By:</b> " + postedBy + "<br />");

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
use single quotes  instead of double quotes

Author

Commented:
thanks for reply, tried your solution but this is what I get:


sb.AppendLine("<a href='#' onclick='openEditPostWindow('<%# DataBinder.Eval(Container.DataItem, 'ID') %>'); return false;'>edit your post</a><br />");
the results are:

'); return false;'>edit your post

shows as link, but also shows the '); return false;'>   text instead of just edit your post  also when I click on link does not fire the onclick event

Now
this openeditpostwindow ,is that javascript function available in the page.
Next whe you put your eval expression within quotes,that would become a normal string.
Can you post the full code here

Author

Commented:
i got it, i replaced eval expression with variable and passed it back so your first solution worked, thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial