Requesr.QueryString()方法抛出异常 [英] Requesr.QueryString() method throw exception
本文介绍了Requesr.QueryString()方法抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我 已写入 javascript function to open new 窗口 和 传递 参数跨度>。 然后 我 使用 request 。 Querystring method to get 参数 来自 弹出。
但是 如果 它 < span class =code-leadattribute> get any null value 然后 it throw 例外。 exception 对象 参考 不 set to instance object 。跨度>。 我 提供 condition to recover 此 问题。
但是 不 work 。 我的 代码 here :
function strgetStyleNo(){
var a = $( < span class =code-string> [id $ ='ddlStyleNo'])。val();
var b = $( [id $ = 'ddlDefectType']跨度>)VAL();
var d1 = $( [ID $ = 'txtFromDate']跨度>)VAL();
var d2 = $( [id $ = 'txtToDate']跨度>)VAL();
if (a!= ){
window.open( Reports / Smt_StyleWiseReportWindow.aspx?Names = + a + , mywindow, status = 1,toolbar = 1, width = 900px,height = 600px,left = 250,top = 100);
}
如果(b!= ){
window.open( Reports / Smt_StyleWiseReportWindow.aspx?defect = + b + , mywindow, status = 1 ,toolbar = 1,width = 900px,height = 600px,left = 250,top = 100);
}
如果(d1!= ){
window.open( Reports / Smt_StyleWiseReportWindow.aspx?dt1 = + d1 + & dt2 + d2 + , mywindow, status = 1,toolbar = 1,width = 900px,height = 600px,left = 250,顶部= 100\" 跨度>);
}
}
string strStyleCode = ;
string defecttype = ;
if (Request.QueryString [ 名称]。ToString()!= || Request.QueryString [ 名称]。ToString()!= null )
{
strStyleCode = Request.QueryString [ 名称]。的ToString();
}
else if (Request.QueryString [ defect]。ToString()!= || Request.QueryString [ defect] .ToString()!= null )
{
defecttype = Request.QueryString [ defect]。ToString();
}
解决方案
( [ID
= 'ddlStyleNo']跨度>)VAL();
var b =
( [ID
I have written the javascript function to open new window and pass parameter. Then I use request.Querystring method to get the parameter from the popup.
But if it get any null value then it throw exception. The exception is "Object reference not set to an instance of an object.". I have provided condition to recover this problem.
But not work. My code is here :
function strgetStyleNo() {
var a = $("[id$='ddlStyleNo']").val();
var b = $("[id$='ddlDefectType']").val();
var d1 = $("[id$='txtFromDate']").val();
var d2 = $("[id$='txtToDate']").val();
if (a != "") {
window.open("Reports/Smt_StyleWiseReportWindow.aspx?Names=" + a + "", "mywindow", "status=1,toolbar=1, width=900px, height=600px,left=250,top=100");
}
if (b != "") {
window.open("Reports/Smt_StyleWiseReportWindow.aspx?defect=" + b + "", "mywindow", "status=1,toolbar=1, width=900px, height=600px,left=250,top=100");
}
if (d1 != "") {
window.open("Reports/Smt_StyleWiseReportWindow.aspx?dt1=" + d1 + "&dt2"+d2+"", "mywindow", "status=1,toolbar=1, width=900px, height=600px,left=250,top=100");
}
}
string strStyleCode = "";
string defecttype = "";
if (Request.QueryString["Names"].ToString() != "" || Request.QueryString["Names"].ToString() != null)
{
strStyleCode = Request.QueryString["Names"].ToString();
}
else if (Request.QueryString["defect"].ToString() != "" || Request.QueryString["defect"].ToString() != null)
{
defecttype = Request.QueryString["defect"].ToString();
}
解决方案
("[id
='ddlStyleNo']").val(); var b =
("[id
这篇关于Requesr.QueryString()方法抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文