我有以下代码
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ TR/ x html1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Oncall Lookup</title>
<style type="text/css">
.style1
{
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<br />
</div>
<div class="style1">
<asp:Label ID="TimeDateLabel" runat="server" style="text-align: center"></asp:Label>
<br />
<br />
<br />
<br />
<asp:TextBox ID="schednameTextBox" runat="server" style="text-align: center"></ asp:TextBox>
<asp:RequiredFieldValidator ID="schednameValidator" runat="server"
ControlToValidate="schednameTextBox" ErrorMessage="This is a required field">This
is a required field</asp:RequiredFieldValidator>
<br />
Schedule Name<br />
<br />
<br />
<br />
<asp:TextBox ID="sincedateTextBox" runat="server" style="text-align: center"></asp:TextBox>
<asp:RequiredFieldValidator ID="sincedateValidator" runat="server"
ControlToValidate="sincedateTextBox" ErrorMessage="This is a required field">This
is a required field</asp:RequiredFieldValidator>
<br />
Since Date<br />
<br />
<br />
<asp:Button ID="whosoncallButton" runat="server" Text="Who's On Call" />
<asp:Button ID="clearButton" runat="server" Text="Clear" />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="SchedName" HeaderText="SchedName"
SortExpression="SchedName" />
<asp:BoundField DataField="ActivityDate" HeaderText="ActivityDate"
ReadOnly="True" SortExpression="ActivityDate" />
<asp:BoundField DataField="By" HeaderText="By" SortExpression="By" />
<asp:BoundField DataField="Activity" HeaderText="Activity" ReadOnly="True"
SortExpression="Activity" />
<asp:TemplateField HeaderText="Firstlisting" SortExpression="Firstlisting">
<ItemTemplate>
<asp:HyperLink ID="Firstlisting" runat="server" Text='<%# Eval("Firstlisting") %>'
NavigateUrl='<%# String.Format("\website1\Default3.aspx?firstlisting={0}", Eval("Firstlisting")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="OncallStart" SortExpression="OnCallStart">
<ItemTemplate>
<asp:HyperLink ID="OnCallStart" runat="server" Text='<%# Eval("OncallStart") %>'
NavigateUrl='<%# String.Format("\website1\Default2.aspx?date={0}&schedname={1}", Eval("OncallStart"), Eval("Schedname")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OnCallEnd" HeaderText="OnCallEnd" ReadOnly="True"
SortExpression="OnCallEnd" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MDRConnectionString %>"
SelectCommand="sp_getoncallresults2" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="sincedateTextBox" DbType="Datetime"
Name="sincedate" PropertyName="Text" />
<asp:ControlParameter ControlID="schednameTextBox" Name="schedname"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
<asp:Label ID="nodataLabel" runat="server"></asp:Label>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
当我尝试将某些变量传递到下一页时,它们没有被传递。有人告诉我,我的URL字符串中没有说明&符号和黑色。最好的方法是什么?
谢谢
道格
答案 0 :(得分:0)
您需要对查询参数进行url编码:
<asp:HyperLink
ID="Firstlisting"
runat="server"
Text='<%# Eval("Firstlisting") %>'
NavigateUrl='<%# string.Format("~/website1/Default3.aspx?firstlisting={0}", Server.UrlEncode((string)Eval("Firstlisting"))) %>'
/>