asp.net代码 [英] asp.net code
本文介绍了asp.net代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友
查看我的代码
Hello friends
Go through my code
Dim hrefSearch As New HyperLink
hrefSearch = Page.FindControl("hrefAWSearch")
hrefSearch.Attributes.Add("onclick", "javascript:MM_openBrWindow('AW_Search.aspx?ratecardid=" & Request.QueryString("ratecardid") & "','width=450,height=200')")
我正在尝试弹出子窗口,但错误是
I''m trying to PopUp child window, But error is
Object reference not set to an instance of an object.
任何解决方案,哪里出了问题?
Any solution, what is going wrong??
推荐答案
基于当前共享的代码,错误的潜在位置是:
hrefSearch = Page.FindControl("hrefAWSearch")
使用DEBUGGER并查看是否填充了 hrefSearch 对象.
此外,可能Request.QueryString("ratecardid")
也未返回任何内容.您应该在使用前验证它们.
更新1:
在此行仔细查看:<asp:HyperLink id="hrefSearch" runat="server">
超链接ID: hrefSearch
您正在尝试将findcontrol用于ID:href AW Search
试试:
hrefSearch = Page.FindControl("hrefSearch")
Based on the current code shared, the potential place of the error is:
hrefSearch = Page.FindControl("hrefAWSearch")
Use DEBUGGER and see if hrefSearch object is populated or not.
Further, it might be thatRequest.QueryString("ratecardid")
is also not returning anything. You should verify them before using.
UPDATE 1:
See closely at this line:<asp:HyperLink id="hrefSearch" runat="server">
Hyperlink ID: hrefSearch
You are trying to use findcontrol for id: hrefAWSearch
Try:
hrefSearch = Page.FindControl("hrefSearch")
最有可能的是,以下代码未能在Page中找到任何对象,因此返回了Null
.
Most probably, the following code is failing to find any object in the Page and hence returningNull
.
Page.FindControl("hrefAWSearch")
因此,您将在下一行获得Null异常.
尝试调试,以便使用正确的控件名称正确调用FindControl()
方法.
希望这会有所帮助.
So, you are getting the Null Exception in the very next line.
Try debugging so that, the FindControl()
method is invoked correctly with correct control name.
Hope, this helps.
这篇关于asp.net代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文