Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 超链接NavigateUrl的正确语法_C#_Asp.net - Fatal编程技术网

C# 超链接NavigateUrl的正确语法

C# 超链接NavigateUrl的正确语法,c#,asp.net,C#,Asp.net,在Index.aspx页面中,我使用一个超链接并传递到ShowIndexRegular.aspx 2变量:key和flag { ........ string key="3"; string flag="0"; HyperLink1.NavigateUrl = string.Format("ShowIndexRegular.aspx?key={0},flag={1}",key,flag); } 在ShowIndexRegular.aspx中: 当我单击

在Index.aspx页面中,我使用一个超链接并传递到ShowIndexRegular.aspx 2变量:key和flag

{
     ........
     string key="3";
     string flag="0";
     HyperLink1.NavigateUrl = string.Format("ShowIndexRegular.aspx?key={0},flag={1}",key,flag);

}
在ShowIndexRegular.aspx中:

当我单击Index.aspx中的Hyperlink1时,即使在地址栏显示:http://localhost:41148/website/ShowIndexRegular.aspx?key=3,标志=0

结果始终为0,表示该标志为空。我真的不知道为什么,地址栏显示:key=3,flag=0

我的超链接导航EURL语法有错误吗??? 救命啊

见下文

HyperLink1.NavigateUrl = string.Format("ShowIndexRegular.aspx?key={0}&flag={1}",key,flag);
您试图使用错误的格式构建查询字符串。用我上面的代码替换你的代码,你会没事的。

见下文

HyperLink1.NavigateUrl = string.Format("ShowIndexRegular.aspx?key={0}&flag={1}",key,flag);

您试图使用错误的格式构建查询字符串。用上面的代码替换您的代码,您就没事了。

查询字符串不会用逗号分隔键/值对:

ShowIndexRegular.aspx?key={0},flag={1}
相反,它们通过与符号分隔键/值对:

ShowIndexRegular.aspx?key={0}&flag={1}

查询字符串不按逗号分隔键/值对:

ShowIndexRegular.aspx?key={0},flag={1}
相反,它们通过与符号分隔键/值对:

ShowIndexRegular.aspx?key={0}&flag={1}

这不是传递多对查询字符串的正确方法,您只需使用&而不是,如下所示:

{ ........ 字符串键=3; 字符串标志=0; HyperLink1.NavigateUrl=string.FormatShowIndexRegular.aspx?key={0}&flag={1},key,flag

}

这不是传递多对查询字符串的正确方法,您只需使用&而不是,如下所示:

{ ........ 字符串键=3; 字符串标志=0; HyperLink1.NavigateUrl=string.FormatShowIndexRegular.aspx?key={0}&flag={1},key,flag

}