与代码共舞加v:EternAl_OcT,备注it行业
1.aspx.cs中获取aspx页面url?report=后边的路径(方法1)
string pptUrl = Request.QueryString["report"];
2.aspx.cs中获取aspx页面url?report=后边的路径(方法2)
string ppturl=null;
string url = Request.Url.Query;//截取aspx页面?后的url
if (url.Contains("report="))
{
try
{
ppturl = Regex.Split(url, "report=", RegexOptions.IgnoreCase)[1];
ppturl = ppturl + "1";//测试,可以删掉
}
catch (Exception)
{
ppturl = "";
}
}
3.js中通过aspx传递值
$("#id").attr("src", "WebForm1.aspx?report=" + ReportPath);
4.js中获取aspx页面的上的路径
function aaa() {
var str = location.href;//获取aspx页面上的路径
url = str.split("report=")[1];//截图部分路径
decodedStrurl = decodeURI(url);//js中停止url中中文转码
//document.writeln(decodedStr); // js中输出相当于alert
}
5. aspx.cs获取html的input中name值
html: <input id="oo" name="StarDate" type="text" style="width:200px;margin-right:20px;"/>
aspx.cs:string StarDate = Request["StarDate"].ToString();