c# - 在 C# ASP.net 中通过 URL 传递参数

标签 c# asp.net

我有以下用于按钮单击事件的代码,我在其中为报告打开一个新选项卡,我需要将参数从后面的代码传递给它,

String classname = txt_classname.SelectedValue;
String teachername = "Some name";


string url = "Report_Classwise.aspx";
string s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);

我需要将类(class)名和教师名传递给 Report_Classwise.aspx 页面,我试过设置

string url = "Report_Classwise.aspx?classname='"+classname+"'&teachername='"+teachername+"'";

但是没用

最佳答案

您不需要在 URL 中添加额外的单引号

string url = "Report_Classwise.aspx?classname=" + classname + "&teachername=" 
+ teachername;

关于c# - 在 C# ASP.net 中通过 URL 传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23852272/

相关文章:

c# - 从表单打印面板时分辨率不佳

c# - 无法在计算机上打开服务控制管理器

c# - 错误操作编辑 Controller MVC

c# - Visual Studio 2017 中的高级代码格式化

c# - Android应用程序解密所需的IV存储在哪里?

c# - 违反了哪些 SOLID 原则? (我应该怎么做才能解决这个 Controller 问题?)

c# - 如何在 iTextSharp 中同时显示单元格的底部和顶部边框?

asp.net - Visual Studio 2008 - 无法命中断点

c# - wpf 菜单选项卡停止奇怪的行为

c# - dotnet 核心 : discontinued? 中的 Vue.js 模板