English 中文(简体)
Concatenating a string in a querystring of a <a> link in c# created through asp.net
原标题:

I can already send something in the querystring:

<a href= Exibe.aspx?var= lalala  >

but I d like to send a string instead of lalala, and when i try to concatenate normally in the response.write with "+" signs, it just doesn t. it creates the url only with the part before the "+".

Facts:

  • the string has a value
  • I can concatenate it with other string and it works
  • I can use the querystring with something I write

Thank you

UPDATE: code that doesn t work:

responde.write("<a href= Exibe.aspx?nome= " + nome(0) + "  > click here </a>");

Code that works but doesn t do what I want (sends "VALUE" not my string)

responde.write("<a href= Exibe.aspx?nome= VALUE  > click here </a>");

I m really new at this.. sorry

最佳回答

Are you looking for HttpUtility.UrlEncode or are you looking for something to build the Uri like UriBuilder ? Either way you should be able to google up some examples.

问题回答

Why not simply use a hyperlink server control? That way you have full control over the link element from you re code:

<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>

HyperLink1.NavigateUrl = "http://whereever.com/Default.aspx?Blah=whatever";

Also, with query strings you dont need to use quotation marks around each parameter.

This:

response.write("<a href= Exibe.aspx?nome=VALUE > click here </a>");

Will pass the string "VALUE" through.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签