[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2700
  • Last Modified:

How to add object to script control in VB .NET 2008 Express

Hi

I am using Microsof Visual Basic .Net 2008 and Dot Net framework 3.5.

I'm using the following code.

Dim ScriptCntrl as New MSScriptControl.ScriptControlClass
Dim ObjTexbox as new TextBox
ObjTexbox.Name = "txtFirstName"

ScriptCntrl.AddObject(objTextBox.Name,objTextbox,true)


when I m executing the above code I'm getting following error

"Specified Cast is Not Valid"

What is the solution?





0
infowareindia
Asked:
infowareindia
1 Solution
 
Arthur_WoodCommented:
Are you sure that the ScriptContol.AddObject method accepts 3 arguments?  I am looking at the Microsoft page on the Script Control metjods, and AddObject appears to accept 2 (TWO) arguments, the Name (as a string), and the ControlObject, to be identified by that name.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
It works for me...after fixing the typos and setting a Language.  The name of the textbox wasn't consistent:

        Dim ScriptCntrl As New MSScriptControl.ScriptControlClass
        ScriptCntrl.Language = "VBScript"

        Dim ObjTextBox As New TextBox
        ObjTextBox.Name = "txtFirstName"

        ScriptCntrl.AddObject(ObjTextBox.Name, ObjTextBox, True)
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now