Response.Redirect problem

Last post 12-02-2004 12:13 PM by stevenbey. 5 replies.

Sort Posts:

  • Response.Redirect problem

    11-30-2004, 11:47 PM
    • Member
      350 point Member
    • seitechs
    • Member since 07-26-2004, 7:04 PM
    • Virginia
    • Posts 72
    Hi all,

    I have a control were I dynamically add child controls, ascx pages, to a placeholder based on a menu selection. I finally have the controls working properly but my child controls contain submit and cancel linkbuttons. All the events fire fine but my response.redirect throws a "Object reference not set to an instance of an object" error. I use the same redirect statement in the main control and everything works fine so I know it works. I need this to work to redirect back to a main control. I have included to code below for the main control and the child control.

    Thanks....


    ----------------------------------This is the entire error--------------------------------------
    InnerException: System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Exceptions.ProcessModuleLoadException(PortalModuleControl ctrlModule, Exception exc)
    at LCGI.DNN.Modules.PTT.Company_Settings.cmdCancel_Click(Object sender, EventArgs e)
    in C:\Virtual Directories\2.2\DesktopModules\PTT\Controls\Company_Settings.ascx.vb:line 179 at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
    at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
    at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain()



    -----------------------------------------Main Control-------------------------------------------

    Private Sub ctlDashboard_MenuClick(ByVal ID As String) Handles ctlDashboard.MenuClick
    _MenuID = Convert.ToInt32(ID)
    Session("MenuID") = _MenuID
    _MenuClick = 1
    LoadPTTControl()
    End Sub

    Sub LoadPTTControl()
    Dim controlName As String = "Main.ascx"
    If _MenuClick = 1 Then
    Response.Redirect(NavigateURL(), True)
    End If
    Select Case _MenuID
    Case 1
    controlName = "Main.ascx"
    Case 50
    controlName = "Company_Settings.ascx"
    End Select

    contentControl = Page.LoadControl(("~/DesktopModules/PTT/Controls/" & controlName))
    plhContent.Controls.Clear()
    plhContent.Controls.Add(contentControl)
    contentControl.ID = "ctlContent"
    End Sub 'LoadTab


    -----------------------------------------Child Control-------------------------------------------

    Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
    Try
    Session("MenuID") = 1
    Response.Redirect(NavigateURL(), True)
    Catch exc As Exception
    ProcessModuleLoadException(Me, exc)
    End Try
    End Sub
    Bryan

    www.lcgis.com
  • Re: Response.Redirect problem

    12-01-2004, 3:16 PM
    • Contributor
      4,840 point Contributor
    • wunderkinder
    • Member since 10-31-2002, 5:42 PM
    • Black Hills of South Dakota
    • Posts 964
    Try using this:

    HttpContext.Current.Response.Redirect(...)
    Jared Livingston
    MrLivingston.com - Take a look at the Livingston Family Web site.
  • Re: Response.Redirect problem

    12-01-2004, 4:23 PM
    • Member
      350 point Member
    • seitechs
    • Member since 07-26-2004, 7:04 PM
    • Virginia
    • Posts 72
    Still get the same error. Not sure why the same code works if I run the control as a parent control but as soon as I make it a child it bombs.
    Bryan

    www.lcgis.com
  • Re: Response.Redirect problem

    12-01-2004, 4:43 PM
    • Contributor
      4,629 point Contributor
    • Jigar
    • Member since 06-17-2002, 9:41 AM
    • Ridgewood, NJ
    • Posts 935
    System.NullReferenceException: Object reference not set to an instance of an object

    looks like NavigateURL() is culprit in your case. check if it returns the value you are expecting.
    Jigar Desai
    -----------------------
    Do not forget to "Mark as Answer" on the post that helped you.
  • Re: Response.Redirect problem

    12-02-2004, 11:03 AM
    • Member
      350 point Member
    • seitechs
    • Member since 07-26-2004, 7:04 PM
    • Virginia
    • Posts 72
    I have checked the value and is as it should be. I even tried using a literal and it still failed.
    Bryan

    www.lcgis.com
  • Re: Response.Redirect problem

    12-02-2004, 12:13 PM
    • Star
      13,992 point Star
    • stevenbey
    • Member since 10-28-2002, 4:56 AM
    • United Kingdom
    • Posts 2,808

    Does your Company_Settings Class inherit from UserControl or just from Control?

    Edit: Oops, just noticed that it's a .ascx and so obviously inherits from UserControl!

    Steven Bey

    Recursion: see Recursion
Page 1 of 1 (6 items)