Calling A Webpage From Within A Class Module?
Jun 1, 2009
I have been given an ASP.Net assignment at work because I had taken a few courses a couple of years ago. Currently, there are no ASP.Net programmers for me to ask here and I have searched several places (including Pro ASP Net book) to find a solution but have come up empty handed.
I have a class named spErrors which takes the values passed to it. Values passed include the offending page,function/sub, and other values and stores them in property values, then calls Response.Redirect("Errors.aspx") from the page's code behind page. In Errors.aspx, the values of the error/exception trapped in the Catch statement are displayed. This works fine from a web form. My question is, how do I call a web page from a class module?
Each class module has the ErrorHandler() procedure that passes these values to the class object. In the class, there is a Write Only property named Redirect and a method called Execute() which is used to display the error page if the error occurs in another class module. Since Response.Redirect() does not work in a class module, what namespace is needed in order for this to work?
Here is the code I'm using.
In the Catch block.
Catch ex As Exception
Err.Description = ex.Message
ErrorHandler(Err, "function name")
[code]....
View 2 Replies
ADVERTISEMENT
Sep 24, 2010
I have an 100 aspx files with one module file for code. All these aspx files have the same backend function, so i created on public module for all these files to access. These files are in the same folder. But for some reason the aspx files cannot access the function from that module.
mod1.vb Code (.vb file)
Public Module Allinone
Sub Allinone_Load(ByRef Page As Web.UI.Page)
[Code]....
I am at a roadblock of why the aspx files wont read this module? Also all these files are in the same directory
View 1 Replies
Sep 29, 2009
I have a console application consisting of two modules. One module named "quote" is the main module for the application. Another module named "common" contains commonly used functions and subroutines that are shared between multiple applications.
In the "common" module is a function named "quote". If I attempt to call the "quote" function from the module named "quote", then I get the following error: Error 1 'quote' is a type and cannot be used as an expression. However, if I copy the quote function from the "common" module to the "quote" module, then I no longer receive this error.
There shouldn't be an issue with calling a function that happens to have the same name as a module, but only when that function is located in a different module.
View 2 Replies
Aug 6, 2011
I would love to use the following procedure to set the Title, keywords etc. of my pages, in a module.
Public Shared Sub SetTitle(ByVal Heading As String, ByVal Keywords As String())
Dim myMaster As Masterpage = DirectCast(Me.Master, Masterpage)
If Request.QueryString("lng") = "es" Then
[Code]....
The problem is that i get two errors.
At Me.Master i get the 'Me' is valid only within an instance method. error and at
If Request... i get the error
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
So how do i fix these? I would like to have that procedure in a common place and not in every page.
View 1 Replies
Dec 15, 2011
I am developing a VB net application with lots of TextBox. I need to call a module everytime any of the textbox gets focus. I dont want to write code in every textbox gotfocus event, but a generic code which will call the module everytime any textbox gets focus.
View 6 Replies
Jun 10, 2011
I'm writing a program in vb.net 2003 and have come up with a problem.
I have a sub SettingsSave() in a module.
Public Sub SettingsSave()
Dim frmSaveSettings As New frmSettings
MsgBox frmSaveSettings.txtName.Value 'for testing purposes
SaveSetting("MyApp", "configs", "Name",frmSaveSettings.txtName.Value)
SaveSetting("MyApp", "configs", "Pass",frmSaveSettings.txtPass.Value)
End Sub
I have a form frmSettings, which has a button btnSave. When the button is clicked, SettingsSave() is called.The problem is, if btnSave is clicked, then either of the two textbox values are changed, then btnSave is clicked again, the SettingsSave() sub still returns the 'old' values (from the first time the save button was clicked).How do I clear the old values from memory? I've tried adding frmSaveSettings = Nothing, and frmSaveSettings.Close at the end of the sub SettingsSave().
View 5 Replies
May 25, 2012
I have an application (app.exe) that has a VB Module in its source code (Module1). The module has a function called Function1. I need to call this function from another application. The module is not marked as public, so adding a reference to app.exe won't work. I'm trying to use reflection (Assembly.LoadFrom()) but unless I'm way off base, the module would have to be a class in order for me to get an instance of it.
Please nobody ask me "what have you tried?" I tried a million different things and let's just say "none of them work." So I'm looking for someone that has specific experience with doing exactly what I'm trying to do. If you don't have that experience, please move on to the next question and ignore mine.
View 1 Replies
Aug 25, 2009
I have a Sub Routine in a module to iterate controls on a form. I get an error about an instance of the object not created.I have declared the object and set it to the form (ModelsBox = Me). I have done this between two forms previously. Is there something fundamental that I am missing. Is this where the "Friend Shared" comes into play?
[Code]...
View 2 Replies
Jul 20, 2009
Im new in this forum. I just recently upgraded my Visual Studio 2003 to Visual Studio 2008.I have a web project which is working very well in Visual Studio 2003. But when Im trying to run the same project in Visual Studio 2008, Im getting a runtime error message.The error message is about a public function which is defined in a public module. When Im trying to call that function from different web pages of my project, the web pages are not recognising the public functions and asking me to
View 3 Replies
Apr 5, 2010
I am using VB2008 In the Form1, i have coded
Public Function getText(ByRef ctlName As String) As String
getText = Mfg.get_TextMatrix(Mfg.Row,Mfg.Col
[Code]...
View 5 Replies
Apr 24, 2010
I don't know enough about VB.Net yet to use the richer HttpWebRequest class, so I figured I'd use the simpler WebClient class to download web pages asynchronously (to avoid freezing the UI).
However, how can the asynchronous event handler actually return the web page to the calling routine?[code]...
View 2 Replies
Nov 16, 2009
I' ve got a short question concerning BackgroundWorker.Is it possible to have the main code for the BGW in one class and the long process for the BGW (DoWork) in another class or module?
I couldn't find anything helpful on the internet.Here is my code - DoWork in a separate class doesn't work:
[Code]...
View 15 Replies
May 13, 2009
I have a module1.vb that contains a public sub, for example
Public Sub LogEvent(ByVal strIn As String)
Dim objLogFile As Object
objLogFile = frmEventLog.txtLog
[code].....
View 15 Replies
Nov 13, 2009
What is a driver module, and how would I add a class and get the driver module to read from the class.
View 2 Replies
May 13, 2011
Example:
Two files - TestClass.vb, myForm.vb
TestClass.vb looks as follows:
Imports System.Threading
Public Class TestClass
Private myClassThread As New Thread(AddressOf StartMyClassThread)
[code]....
The result:Application runs, no errors or exceptions.Displayed is the listbox and the Start button.I press the start button and a msgbox says "Not Invoked" as expected and upon clicking OK to that msgbox "Start Button Pressed" is added to the Output listbox control.Immediately following that the msgbox pops up again and says "Not Invoked". I was expecting "Invoked" as a separate thread is trying to use the Output listbox control.Of course this results in the Output.Items.Add being attempted which results in no visible result as the thread is not allowed to directly update the UI control.
View 1 Replies
Jan 12, 2011
Some of my co-workers make extensive use of the VB.net concept of Modules. Unfortunately, I just don't 'get it'. I see no benefit in using modules over shared classes. When would it be preferable to use a module?
View 2 Replies
Jun 17, 2012
Use a DLL rather than a module so that if I updated the DLL it would propagate over all the projects that used it. I want to create a library of functions and subroutines that may be used in many projects (such as my gradient and some error messages).
View 8 Replies
Apr 18, 2011
This is purely a coding practice question concerning VB.NET structures. Where do you keep one?As an example, I've created a structure for the simple purpose of keeping information organized, I'd like this structure to be stand-alone, not belonging to any class so I wouldn't have to access it through SomeClass.MyStructure but rather simply MyStructure. So, do I keep it in a separate class and import it into my namespace? Do I keep it in a module (Static class, essentially)? Do I just make a separate VB.NET code file and place is there (I would like it to live in a separate file). Just to clarify, I need this structure to be accesses by the whole application, not just a single class.
View 1 Replies
Mar 6, 2009
I'm working on a program that I have 90% finish.Its basically validates certain information such as credit card, telephone numbers, name etc...
Im trying to create a separate class 'IsValid'to figure out if the creditcard number is valid (is equal to 12 characters only).
This will be initiated with a "Validate button".I know how to do this in the mainform just using an If statement.
But I'm trying to figure out how to valid date this and return it to the form and possibly change cardnumber.forecolor = color.red
View 7 Replies
Sep 6, 2010
Recently i studied about Module and i think it is a Shared Class and all its members are Shared by default and we can not change that. I have query that is it doing something special that a class can not do ? I have just tried with a simple example and found that classes even do a Module's job.Below is my code:
[Code]...
View 7 Replies
Aug 6, 2011
I got a problem with this piece of [code]...
The problem is that i want to move the >>dim dataLoad...<< to a different file (a config file), but when i move it, i get bunch of errors. And i do call the class/module but still it wont work.
Also the other question is how to download multiple files from a server, so when they are downloaded they stay/ are placed in the corresponding folder.
View 2 Replies
Sep 11, 2011
I am using Joe Mayo's book Visual Studio 2010 A beginners guide and in it he suggests that the default Module Module1 should be replaced with a Class and that it was a hold over from previous versions of VS. How can I change VS's behavior so it defaults to Class Program instead?
View 4 Replies
Oct 31, 2010
Im going through the 2008 Express tutorials on methods and classes. Since the advantage of subs, functions, methods, etc is their reusability, how does one save them and later import them into an application?
Also when one writes a class, how is it tested without being part of a form? Besides testing a class, why would one wants to write a class without a form, if it is to be published for a user?
View 3 Replies
Nov 30, 2011
Currently i am using a class thats created and amended on startup and then passed as needed to other class constructors as needed. Now my project is around 20+ classes i am getting tired of passing each new instance this class. Would a module be more suited?
View 14 Replies
Mar 1, 2010
Any some simple examples of how arrays can be put in a Class Module? The examples should show how the array is used and accessed in a form.
View 3 Replies
Jul 13, 2011
When loading the buttons to the class I keep getting the 'Null Reference Exception was unhandled' error. How can I fix it? Here is the code...
Class Module:
Public Class Buttons_Group_Class
Public WithEvents Button_Group As System.Windows.Forms.Button
Sub Button_Group_Click()
[code]....
View 7 Replies
Mar 29, 2010
I have no idea what is going on here but it is strange to say the least.I created a new solution in VS2008Pro under windows 7 This solution has 2 projects one for the pc and one for a CE based device.There is one class module which is shared between the 2 projects.In VS2005 under xp this same basic project worked fine but here I am seeing error messages that appear out of no where.
Example the CE portion flags 3 lines initially 1 related to a file i.o function and 2 others related to socket methods. All three of these were supported in VS2005 using framework 2.0 which is the same framework I am using here. This is just the tip of the ice berg however.If I attempt to run the code it runs fine for the pc client and of course not for the CE device. If I make any kind of change, add a line, comment a line or just add a comment I get lots more errors with odd messages that are not even valid.
In one case after I saved it jumped from 3 errors to 30, in another case to 50 and yet another to 144 errors yet the only errors that were present were the original 3 that were flagged.The ide threw errors like Try Catch must end with matching End Try.Get no longer supported ' apparently referring to the binary file get but here it is used as the get portion of the property.Get must end with matching end get.It also started complaining about functions and data types.For example saying "an is not declared" pointing to the word Boolean Or telling me my functions are not declared point to only 1/2 of the function name.
I do not see any errors in the code and it reports no errors in VS2005 under XP.As a test I tryed adding a new property to the project after it was telling me there were 144 errors. I allowed the ide to do most of the work and when I hit enter the errors went back to 3. Then I saved the project and the errors went to 105 pointing first at the new property just created.
View 5 Replies
Feb 23, 2009
I want to know how can convert (compile) a class module into a .dll file. You can refer to me an article, tutorial or a code sample.
View 1 Replies
May 21, 2011
I have a single solution with 2 projects. One project contains all my forms and some other modules and the other project has 1 module with 1 giant class in it. I try to click on properties and change the output type, but it won't let me make it a Class Library, the only 2 options are "Windows Application" or "Console Application". The startup object is the module, and the project has references to a socket component.
View 2 Replies
Dec 3, 2009
I am trying to convert following code into a VB equivalent so that I can use it with threading my forms and controls.
using
System;
using
System.Collections.Generic;
[code]....
View 3 Replies