RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

C# Syntax Question

Protius73

Sorceror
Ok im writing a website project for a friends freeshard but i have a small dilemna in the C# code behind for the page.

Code:
<asp:HyperLink ID="imagelink" NavigateUrl='<%# Bind("Name", "/images/pvp/{0}") %>' runat="server" Target="blank">

That is the current hyperlink control that currently works and adds the hyperlinks to all the images for said folder.

Now in the C# i have a method to switch the value of NavigateUrl to a new databinding

Code:
        HyperLink imagelink = (HyperLink)DataList182.FindControl("imagelink");
        string newLink = '<%#Bind("Name", "/images/pve/{0}") %>';
        imagelink.NavigateUrl = newLink;
the Problem is the value for newLink isnt in a proper format for C# so how would i format that string to work correctly ?
 

Jeff

Lord
Code:
string newLink = "<%#Bind(\"Name\", \"/images/pve/{0}\") %>";

A string is repreesented by the " (quote), and ending with the same. If you need to put a quote inside the string, you put a \ (forward slash) in front of it, this is know as an escape character.
 

Protius73

Sorceror
Code:
string newLink = "<%#Bind(\"Name\", \"/images/pve/{0}\") %>";

A string is repreesented by the " (quote), and ending with the same. If you need to put a quote inside the string, you put a \ (forward slash) in front of it, this is know as an escape character.

Thanks that solved that problem. You the man Jeff.
 
Top