I am new to Visual Studio.NET but very familiar with the old ASP (using DreamWeaver).I am unfamiliar with this system of having seperate files for VB code and HTML, in my Visual Studio project I have a Default.aspx file and a Default.aspx.vb file. Now I want to declare a variable that will be accesible to all my functions on the Default.aspx.vb file. I.e. if a user clicks on one button and it launches a Protected Sub called Button1_Click, I want that button to be able to read or write to that variable and then if a user clicks on another button, I want it to likewise be able to read and write to that variable.So where should these variables be dimmed?
At the top of the aspx.vb file? Before or after the line that says "Partial Class _Default"?Or at the top of the aspx file? (Within <% %> brackets?)
Does the memory used in declaring variables are reclaimed by the OS when these variables go out of scope?Does the memory used be released by setting thier value to nothing? if not, then how can I force the garbage collector to run or excecute at a certain/desired time..How about in Windows Forms..How can we make sure that the memory used in initializing and showing forms be released if those forms were closed?
I have just been experimenting with nesting classes within a User class I had already created.
E.g.
Friend Class User [Number of Properties...] Friend Class Address
[code]....
I get the same error message!!! "Declaration expected". Also I notice the variable's name is not coming up in intellisense. I have not come across this before as declaring an using variables and objects has been straight forward up until now.
I've created a 30 point wizard. Every step gathers between 1 and 3 variables. I've created a module and publicly declared the variables there. At the end of the wizard, one master form opens, gets all the variables, and displays them on one form. At this point calculations are run too which populates more variables. This works fine for one instance of the process.
the user may want to be running two instances of the wizard at once. Obviously, if the previous wizard is part complete and they start a new one, the variables are going to get crossed or replaced by the new wizard.Is there a way for the variables to be declared publicly but used in multiple instances?
What's the proper way to declare variables in a class? I've been doing something like:
'in a class public shared teststring As String = "first" 'on a code behind
[Code]....
with shared variables loading a second window or reloading the page (without clicking the button) renders the hello world string. so how do I declare variables in a class but make it per instance?
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Dim chatters As List(Of Chatter) = New List(Of Chatter) chatters.Add(New Chatter(New Guid("CD863C27-2CEE-45fd-A2E0-A69E62B816B9"), "Me")) chatters.Add(New Chatter(Guid.NewGuid, "Juan")) chatters.Add(New Chatter(Guid.NewGuid, "Joe")) Application.Add("Chatters", chatters)
[code]....
I am unable to understand last 3 lines that are bold and underlined. Please what is hppening here. Chatter and Chat are two classes defined in App_Code folder. Is there any sight that contains all possible ways to declare and initilaze variables and data structure:
Dim chatters As List(Of Chatter) = New List(Of Chatter)
I need to write a simpe calc. program to add, mutiply, subtract and divide. I want to have two textboxes that I enter numbers in and when I click a button, +,-,/ or * a third text box will display the result.Rather than declaring my variables inside each instance of a click event I would like to declare them globally so I just need to perfom the calculation on them and display result. However declaring them globally doesn't work for me. I;ve tried the variables inside the btnAdd click event which works, but as I said I'd prefer to declare them onece globally.
Public Class Form1 Dim number1 As Double = CDbl(txtNum1.Text) Dim number2 As Double = CDbl(txtNum2.Text)[code]...
I am writing a program and i need to declare matrices but there will be a different number to declare everytime the program is run so I was wondering if anyone knew how to declare them inside a for loop
eg.
For i = 1 to NumberOfMatrices Dim matrix i (5,5) As Double Next
I am new to the forum and new to the visual studio set up and have been working at a practical at home and have ran into some difficulty. The notes say that I am to declare several module variables below the section entitledI have the rest of the form complete but have been unable to locate where I am to place this code
Is it possible for a class of exposing a type for function returns, without allowing users of that class to create variables of that type? A couple usage scenarios:A Fluent interface on a large class; a statement like "foo=bar.WithX(5).WithY(9).WithZ(19);" would be inefficient if it had to create three new instances of the class, but could be much more efficient if the WithX could create one instance, and the other statements could simply use it.A class may wish to support a statement like "foo[19].x = 9;" even when foo itself isn't an array, and does not hold the data in class instances that can be exposed to the public; one way to do that is to have foo[19] return a struct which holds a reference to 'foo' and the value '19', and has a member property 'x' which could call "foo.SetXValue(19, 9);" Such a struct could have a conversion operator to convert itself to the "apparent" type of foo[19].In both of these scenarios, storing the value returned by a method or property into a variable and then using it more than once would cause strange behavior. It would be desirable if the designer of the class exposing such methods or properties could ensure that callers wouldn't be able to use them more than once. Is there any practical way to accomplish that?In formulating a question, it's difficult sometimes to draw the line between complicated usage cases, and simpler usage cases which aren't quite so important. Here's another usage case, and one closer to the one I'd be most interested in (though I'm also interested in Fluent chaining; being able to have something behave like a C++ reference to a value type would be nice, but probably too much work to bother with).I have a type which is somewhat like the Windows registry, in that it is a hierarchical collection of items, each of which may have a string value, an integer value, and/or a nested collection of items. I wish to be able to support the following types of usage:[code]As for the Fluent interface, my thought would be to have the WithXXX properties return a new instance of a derived class which shadows (not overrides!) the WithXXX properties with versions that simply modify the current instance. The return object from WithXXX would be known to be of the derived class, and would thus use the shadowed WithXXX methods, but once it was assigned to a variable, it would be regarded as an instance of the base class, so the next WithXXX would create a new instance.
C++ a stronger concept of value types than C# or vb.net, including the very useful concept of references to value types; it ensures that references to value types cannot be persisted outside the scope of the type in question. Unsafe code in C# can use pointers to value types, but they don't have the protections offered by C++ references.
I'm wondering about the performance differences between imports and inherits in a .net app.I currently program by creating multiple classes that logically define my objects. e.g. a class for customers, users and product.When i want to use these classes in a page i have to import them eg. "Imports Custmomers" and then later in my code i have to create a variable and datatype it before i can use the sub routines and functions from class.I understand from a coding perspective this keeps it all neat and tidy.So my question Would it be not better to combine all my classes into a base class, inherit that base class, rather than import it, when i want to use it and so cut down on the extra declarations and associated code that come from importing a class; and if i did this would it aid performance?
In my .aspx.vb file I have some more code that will put totals into an array for each column like so:
Dim cols(4) As String Dim itms As ListViewItemType For i As Integer = 1 To term 'start for loop for payments caculations
[Code].....
If you are wondering about error 1 that error has nothing to do with the other two errors, it's a formatting error.
I am not sure what I am doing wrong at this point, I have tried to Google it but no luck. Basically I need 4 columns on in my ListView that each row will be able to add data to.
I wanted to display my current logged user data in my aspx web page.But I am unable to do so. I just can't understand how to call the necessary data. I have used Grid view but I cannot find a query that will give me the details of the current logged user.
Code: HttpContext.Current.User.Identity.Name
but it gives me an error saying "property access must assign to the property or use its value". I don't know how to tackle this.
In re-engineering a windows forms application, I find that a lot of code-behind in the various form classes is duplicative and I'm trying to centralize as many procedures as possible into a base class which can be inherited and used by the subclassed forms.
This process seems to be going well and is making the code in my subclasses much simpler and hopefully easier to maintain, but I'm not sure where to draw the line between leaving code in the subclasses and engineering for generic resusability and moving it to the base class.
Specifically, in some subclasses I have code which manipulates variables and objects specific to the subclass, and although I could move the code-behind into the base class, the base class code references specific objects which are needed to compile. For example, each subclass manipulates a databound datagridview and form detail controls which allows the user to select between multi-record and detailed single-record views of a datatable.
In Visual Basic 2008 do I need to declare dummy data objects in the base class so that the base class will compile? Or is there a way to indicate that the data objects will be provided by the subclass?
I have two aspx pages. I need to send a textbox(record_id) value as a parameter from page1.aspx to page2.aspx to be utilized within a SqlCommand query in the VB code behind page. I would like to pass this parameter using the session. Page1 is a gridview which displays records from a sql datasource and on the edit button click the user is redirected to page2 which populates several textboxes and drop down lists and allows the user to edit the record.
If Page1.aspx opens Page2.aspx in a window, how can I have Page1.aspx refresh once Page2.aspx is closed?I have a page with data on it and I have a LinkButton set up so the user can edit that data. The LinkButton launches another windowed page with some text fields and a "Save" & "Cancel" button. Once one of those clicks I execute a save and close the window OR just disregard the information and close the window. I was hoping to have the initial window with the data on it refresh once the 2nd window is closed.
I've had the same problem a couple of times with different ASPX pages after renaming them and I am surprised that I can't find someone else with the same problem on stackoverflow.When I run my ASP.NET C# project, the debugger gives me a message like this one.
Error 5 The name 'txtTitle' does not exist in the current context
It seems that the aspx and aspx.cs files at no longer bound. The only fix I have found for this is to recreate the page and copy/paste my code. how to fix this without recreating the whole thing?
I have two asp pages. a.aspx is layout and b.aspx is content. I want to display the contents of b.aspx inside a <div> on a.aspx. I know with PHP you can do it like so:
I have two webpage in my website namely Default.aspx and Default2.aspx
I have asp.net textbox1 and button1 inside Form tag in Default.aspx page
and i have textbox1 inside form tag in Default2.aspx page
i want when i wanna transfer the textbox1 text of default.aspx page into default2.aspx textbox1 text hidden parameters ... which will not show query string in address bar and transfer value from one page to another..
When i try to use this it gives error: txtSearch is not accesible? what am i doing wrong here? This is not complete code just a snippet. But i think it gives an idea what am i trying to do.