This is a migrated thread and some comments may be shown as answers.

RadAlert not working in VB class

3 Answers 72 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Kishor
Top achievements
Rank 2
Kishor asked on 21 Aug 2013, 08:28 AM
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

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Aug 2013, 02:09 PM
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.
0
Kishor
Top achievements
Rank 2
answered on 22 Aug 2013, 03:41 AM
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
0
Shinu
Top achievements
Rank 2
answered on 22 Aug 2013, 12:34 PM
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.
Tags
Editor
Asked by
Kishor
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Kishor
Top achievements
Rank 2
Share this question
or