473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting error referencing Hyperlink from code-behind

Hi guys...
I must be going brain dead from working on this project for 80 hours in the
last week. I suppose that's part-time for some coders.. anyway...

I created a simple Hyperlink in a user control:

<asp:HyperLink id="lnkRefine" runat="server" >Refine Search</asp:HyperLink>

In the code behind I am trying to set the NavigateURL depending upon a
condition. I include the entire Sub since it may reveal what I am doing
wrong:
----------------------------------------------
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim lnkRefine As HyperLink = FindControl("lnkRefine")

If Not IsDBNull(lnkRefine) Then
If strPassthru = "passthru" Then
lnkRefine.NavigateUrl =
"~/Search/SearchDetail.aspx?page=base&searchId=" & strSavedSearchID
Else
lnkRefine.NavigateUrl = "javascript:history.go(-1)"
End If
End If

End Sub
------------------------------------------------------

Since the code gets past the If Not IsDBNull(lnkRefine) I assume (maybe
incorrectly) that the control was found and object reference instantiated.
On the line:

lnkRefine.NavigateUrl = "~/Search/SearchDetail.aspx?page=base&searchId=" &
strSavedSearchID

I am getting the error:
Object reference not set to an instance of an object

Any help would be appreciated... thanks

May 4 '07 #1
2 4902
IsDBNull checks is the passed object is the DBNull object. if pass it a
null, it will return true. IsDBNull should only be used database
datatype classes not general classes.

-- bruce (sqlwork.com)

John Kotuby wrote:
Hi guys...
I must be going brain dead from working on this project for 80 hours in the
last week. I suppose that's part-time for some coders.. anyway...

I created a simple Hyperlink in a user control:

<asp:HyperLink id="lnkRefine" runat="server" >Refine Search</asp:HyperLink>

In the code behind I am trying to set the NavigateURL depending upon a
condition. I include the entire Sub since it may reveal what I am doing
wrong:
----------------------------------------------
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim lnkRefine As HyperLink = FindControl("lnkRefine")

If Not IsDBNull(lnkRefine) Then
If strPassthru = "passthru" Then
lnkRefine.NavigateUrl =
"~/Search/SearchDetail.aspx?page=base&searchId=" & strSavedSearchID
Else
lnkRefine.NavigateUrl = "javascript:history.go(-1)"
End If
End If

End Sub
------------------------------------------------------

Since the code gets past the If Not IsDBNull(lnkRefine) I assume (maybe
incorrectly) that the control was found and object reference instantiated.
On the line:

lnkRefine.NavigateUrl = "~/Search/SearchDetail.aspx?page=base&searchId=" &
strSavedSearchID

I am getting the error:
Object reference not set to an instance of an object

Any help would be appreciated... thanks
May 4 '07 #2
Thanks Bruce...

I'd better not post anymore when I am brain-dead. In fact before the post I
was looking straight at an article that showed the syntax:

If Not (myControl Is Nothing) then ...

I guess I just have to find out why the control is not being found now.

Thanks again.

"bruce barker" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
IsDBNull checks is the passed object is the DBNull object. if pass it a
null, it will return true. IsDBNull should only be used database datatype
classes not general classes.

-- bruce (sqlwork.com)

John Kotuby wrote:
>Hi guys...
I must be going brain dead from working on this project for 80 hours in
the last week. I suppose that's part-time for some coders.. anyway...

I created a simple Hyperlink in a user control:

<asp:HyperLink id="lnkRefine" runat="server" >Refine
Search</asp:HyperLink>

In the code behind I am trying to set the NavigateURL depending upon a
condition. I include the entire Sub since it may reveal what I am doing
wrong:
----------------------------------------------
Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.PreRender
Dim lnkRefine As HyperLink = FindControl("lnkRefine")

If Not IsDBNull(lnkRefine) Then
If strPassthru = "passthru" Then
lnkRefine.NavigateUrl =
"~/Search/SearchDetail.aspx?page=base&searchId=" & strSavedSearchID
Else
lnkRefine.NavigateUrl = "javascript:history.go(-1)"
End If
End If

End Sub
------------------------------------------------------

Since the code gets past the If Not IsDBNull(lnkRefine) I assume (maybe
incorrectly) that the control was found and object reference
instantiated. On the line:

lnkRefine.NavigateUrl = "~/Search/SearchDetail.aspx?page=base&searchId="
& strSavedSearchID

I am getting the error:
Object reference not set to an instance of an object

Any help would be appreciated... thanks

May 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dfgasner | last post by:
Sry I'm very new to VB.net and am trying to create a shopping cart by way of a book that teaches you VB.net along the way. Unfortunatly I'm stuck cuz I ran into this error and I can't seem to find...
2
by: M. Garcia | last post by:
Good day, I created a form where one of its controls stores the hyperlink to a Word document. The form has a command button that opens the folder where the Word documents are kept using a...
4
by: Marco Krechting | last post by:
Hi All, Sorry but I have to create new message since it cannot find the old message to send a reply. Coming back to this hyperlink thing I will try to explain the real problem cause I think we...
3
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
0
by: dfgasner | last post by:
Sry I'm very new to VB.net and am trying to create a shopping cart by way of a book that teaches you VB.net along the way. Unfortunatly I'm stuck cuz I ran into this error and I can't seem to find...
3
by: keithb | last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding the Visible propery of a hyperlink control to a DataTable text field. The error goes away if I replace the data binding...
1
by: KRISHNA PRAVI | last post by:
the error is "runtime error object expected" here is the code....................................................................................... <script language="javascript"...
6
by: vspsdca | last post by:
Hi, I'm a newbie here and does not really have any formal training on VBA. I just need help to get my hyperlink to work. I have a form in MS Access with a browse button where a user can select a...
2
by: Bobby Edward | last post by:
I have a subdirectory with an aspx page that references a master file located in the root. In the master file template I reference a logo/image that is in <root>/resources... <img alt="logo"...
1
NeoPa
by: NeoPa | last post by:
Error 7980: The HyperlinkAddress or HyperlinkSubAddress property is read-only for this hyperlink I'm struggling with some code to update Hyperlinks in my table. The field is defined as a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.