【发布时间】:2013-07-05 08:46:46
【问题描述】:
我想重定向到另一个页面并仅使用 javascript 传递一些参数。我不应该使用查询字符串。有什么办法可以做到这一点?我正在研究 asp.net。
我希望此重定向与 devexpress 调度程序控件一起使用,当用户单击约会时,通过将所选约会的 ID 作为参数传递,用户将被重定向到另一个页面。它不应作为查询字符串传递。
我也想知道如何从重定向页面中检索这种不可见的参数。
好的,我找到了我的解决方案。
我使用 javascript 单击设置为 style="display:none" 的 <asp:Button>。在我的场景中,我可以获得我单击的调度程序约会的属性。然后,我将这些属性放在隐藏字段中,并在此“不可见”按钮的服务器端单击事件中,使用这些隐藏字段值通过服务器端进行重定向。我的代码如下
<asp:Button ID="Appointment" runat="server" Text="sample"
onclick="Appointment_Click" style="display:none"/>
<asp:HiddenField ID="hfID" runat="server" />
<asp:HiddenField ID="hfSubject" runat="server" />
<asp:HiddenField ID="hfDate" runat="server" />
<script type="text/javascript" language="javascript">
function OnAppointmentClick(s, e) {
//debugger;
var apt = scheduler.GetAppointmentById(e.appointmentId);
var apt1 = scheduler.GetAppointmentProperties(e.appointmentId);
var aptID = document.getElementById('<%= hfID.ClientID %>');
var aptDate = document.getElementById('<%= hfDate.ClientID %>');
var aptSubject = document.getElementById('<%= hfSubject.ClientID %>');
aptID.value = e.appointmentId;
var date = (apt.startDate.getMonth()+1) + '/' + apt.startDate.getDate() + '/' + apt.startDate.getYear();
aptDate.value = date;
aptSubject.value = apt.CODE;
document.getElementById('<%= Appointment.ClientID %>').click();
}
</script>
【问题讨论】:
-
这是你的作业吗? :)
-
没有。这是我的办公室工作。我正在使用 devexpress 调度程序。
标签: c# asp.net c#-4.0 url-redirection