如何将(;,#)符号一页传递给其他页面 [英] How to passing(; , # ) symbol one page to other page
本文介绍了如何将(;,#)符号一页传递给其他页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试将一个页面的数据传递到其他页面时,该数据包含;(分号)后,此分号文本未显示在目标页面中;
假设我有一个文本行
我的名字是brij;这是codeproject如果我试图将这一行传递到其他页面,它只显示
我的名字是brij
如果是#符号则显示错误对象引用未设置为实例对象。
我的尝试:
第一页
受保护 void gotoarticle(object sender,EventArgs e)
{
LinkButton goerticle =(LinkButton)(sender);
string [] argument = goerticle.CommandArgument.Split(' ;');
string id = argument [ 0 ];
string username = argument [ 1 ];
string title = argument [ 2 ];
string tag = argument [ 3 ];
string describe = argument [ 4 ];
string article = argument [ 5 ];
string comment = argument [ 6 ];
string date = argument [ 7 ];
Response.Redirect(string.Format( 〜/ article / article.aspx?id = {0} &安培;用户名= {1}&安培;标题= {2}&安培;标记= {3}&安培; describ = {4}&安培;文章= {5}&安培;注释= {6}&安培;日期= {7} ,id,用户名,标题,标签,描述,文章,评论,日期), false );
}
第二页
protected void Page_Load(object sender,EventArgs e)
{
this .title.Text = Request.QueryString [ 标题跨度>];
this .describ.Text = Request.QueryString [ describ跨度>];
}
解决方案
您是否看过Server.UrlEncode方法?
示例,假设标题和描述包含;和#>
Response.Redirect( string .Format( 〜/ article / article.aspx?id = {0}& username = {1}& title = {2}& tag = {3 }& descript = {4}& article = {5}& comment = {6}& date = {7},id,username,Server.UrlEncode(title),tag,Server。 UrlEncode(describe),article,comment,date), false );
when i try to passing data one page to other page and in that data include " ; "(Semicolon) after this Semicolon text is not show in target page;
suppose i have a text line
"my name is brij ; and this is codeproject" if i try to pass this line to other page, its show only
"my name is brij"
and in case of "#" symbol its show error "Object reference not set to an instance of an object."
What I have tried:
first page
protected void gotoarticle(object sender, EventArgs e)
{
LinkButton goerticle = (LinkButton)(sender);
string[] argument = goerticle.CommandArgument.Split(';');
string id = argument[0];
string username = argument[1];
string title = argument[2];
string tag = argument[3];
string describ = argument[4];
string article = argument[5];
string comment = argument[6];
string date = argument[7];
Response.Redirect(string.Format("~/article/article.aspx?id={0}&username={1}&title={2}&tag={3}&describ={4}&article={5}&comment={6}&date={7}", id, username, title, tag, describ, article, comment, date), false);
}
second page
protected void Page_Load(object sender, EventArgs e)
{
this.title.Text = Request.QueryString["title"];
this.describ.Text = Request.QueryString["describ"];
}
解决方案
Have you look at the Server.UrlEncode method?
Example, assuming title and describ contains ; and # respectively.
Response.Redirect(string.Format("~/article/article.aspx?id={0}&username={1}&title={2}&tag={3}&describ={4}&article={5}&comment={6}&date={7}", id, username, Server.UrlEncode(title), tag, Server.UrlEncode(describ), article, comment, date), false);
这篇关于如何将(;,#)符号一页传递给其他页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文