如何在ASP.NET C#中将多个值存储到href链接中?

3

我希望能够将大量的值存储到这个链接中,以便以这种方式将这些值传递给aspx页面。如何增加值的数量?

htmlBody = string.Format(" Hi "+userName+ 
"\n Thank you for creating an account with RSS MANAGEMENT SYSTEM \n </ br>" + 
"Please click the below link to activate your account <br />" + 
"<a href='http://localhost:2386/ActivateUser.aspx?userName{0}&Id={1}'>Activate {0} </a>",
UName, user_name);

1
我不明白你的问题。你是在问如何增加要替换的格式字符串中的标记数吗? - Quintin Robinson
2个回答

1

你的意思是这样的吗:

var someothervalue=1:
string.format("<a href='http://localhost:2386/ActivateUser.aspx?userName{0}&Id={1}'>Activate {0} </a>{2}", 
UName, user_name,someothervalue)

0

像这样的东西?

var values = new Dictionary<string,string>{ 
                                                {"username", user_name},
                                                {"id", UName},
                                                {"otherparam", "lalala"}
                                         };

var queryString = string.Join("&" + values.Select(x => x.Key + "=" + x.Value));

var link = string.format("<a href='http://localhost:2386/ActivateUser.aspx?{0}'>Activate {1} </a>", queryString, user_name);

我怎样可以从aspx端获取它? - leventkalay92
你说的“get it”是什么意思?在“ActivateUser.aspx”页面中的Request.QueryString["username"],例如。 - Ivo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接