RadAlert not working in VB class

4 posts, 0 answers
  1. Kishor
    Kishor avatar
    82 posts
    Member since:
    Oct 2012

    Posted 21 Aug 2013 Link to this post

    hello sir
    I am using class in my web application
    I want to show errors in Radalert
    I have used following code but it does not work
    it gives error as "Object reference not set to instance of an object"
    please help
       
             Try
            
               Dim Rad As New RadWindowManager
               Dim newWindow As New RadWindow
               newWindow.VisibleOnPageLoad = True
               Rad.Windows.Add(newWindow)
     
           Catch ex As Exception
               Rad.RadAlert(ex.Message, 330, 100, "Error", "")
           End Try
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Aug 2013 Link to this post

    Hi Sawan,

    Since you are dynamically creating the RadWindowManager you need to add the control to your page as shown in the following code.

    VB:
    Dim Rad As New RadWindowManager()
    Me.form1.Controls.Add(Rad)

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kishor
    Kishor avatar
    82 posts
    Member since:
    Oct 2012

    Posted 21 Aug 2013 Link to this post

    hi
    I working in web application
    I don't have forms  

    I want to write this code in Class in App_Code

    so
    Dim Rad As New RadWindowManager()
    Me.form1.Controls.Add(Rad)
    gives error
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Aug 2013 Link to this post

    Hi Sawan,

    I suggest you give the try catch block in the corresponding page code behind instead of giving the same in the class inside App_Code. Even if an exception is generated from the VB code present in the App_Code, the exception will be captured in the catch statement coded in the page code behind and there you can add a RadWindowManager and display the error in a RadAlert. As far as I know the main purpose of App_Code folder is to include the source code for shared classes and business objects and it is not a best practice to include Controls here.

    Please have a look at the following code I tried to display the exception message generated from the VB code in a RadAlert from the corresponding page's code behind. In the following code SqlService is a class in the App_Code folder.

    VB:
    Protected Sub radbutton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles radbutton1.Click
        Dim rad1 As New RadWindowManager()
        Me.form1.Controls.Add(rad1)
        Dim service1 As New SqlService()
        Try
            service1.getDate()
        Catch ex As Exception
            rad1.RadAlert(ex.Message, 500, 200, "Error", Nothing)
        End Try
    End Sub

    Hope this helps,
    Shinu.
Back to Top