vb.net

Using Codedom to write VB.Net Properties

Looking at the example code on MSDN: This ' Declares a type. Dim type1 As New CodeTypeDeclaration("Type1") ' Declares a constructor. Dim constructor1 As New CodeConstructor constructor1.Attributes = MemberAttributes.Public type1.Members.Add(constructor1) ' Declares an integer field. Dim field1 As New ...

Calling a method when a tree node is clicked in the Standard ASP.NET 2.0 TreeView

I have a treeview which i populate dynamically using an XML Datasource. The leaf nodes in the TreeView attempt to open a URL in an iframe within the page. This all works fine, but i would like the iframe to be hidden until the point the leaf node is selected. Does anyone know what event is triggered when the nodes are clicked?? I trie...

VB.NET How do I reduce int to 1 decimal place?

I'm using the code below to convert the file size in bytes (test file is 31718 bytes) to KB (30.974609375 KB) but I want to display this to one decimal place (i.e. 30.9 KB). How would I do this in VB.NET? New FileInfo(FileName).Length / 1024 Thanks ...

Which .Net Framework generic collection type will allow/provide this(key) functionality?

I'm wondering which collection-type in System.Collections.Generic will support this scenario, if there is one: Public Class MyCollectionBase(Of ItemType, KeyType) Inherits System.Collection.Generic.??? Default Public Shadows ReadOnly Property Item(ByVal key as KeyType) as ItemType Get .... End G...

What's the best way to remove white space after a certain character in a string?

I'm trying to build a list that will be used as the in clause of a select statement. The requirement is to have the user enter a comma separated list of descriptions. Each description can contain spaces so I can't remove the spaces before splitting by comma to add the single quotes around each description. I want to remove all white s...

Why won't a Nullable Public Property in a VB.net Class accept 0 (zero) as Assignment?

I have a nullable public property on a class using Vb.net 3.5: Public Property TicketCharge() As Nullable(Of Decimal) Get If _TicketCharge = Nothing Then Return Nothing Else Return _TicketCharge End If End Get Set(ByVal value As Nullable(Of D...

How to recycle data in an SqlDataSource object?

I have an SqlDataSource object, linked to a GridView, which receives data from a database when executed. I'd like to add the values of the "Cost" column, to get the "TotalCost", and place it in a TextBox or Label on top of the GridView. Is it possible to just use (recycle) the data in the SqlDataSource object, instead of using another ...

How should I unit-test a simple CRUD-class?

I am right now trying to do very, very simple stuff with unit-testing in VS2008, to get started and get a feel for this. I think I have testing of small non-database stuff down, but now I want to start testing my real solutions - that are almost always CRUD-heavy. So let's assume I have a class in the data-access layer, that does standa...

Mobile Web Development ?

Hi - I have an existing website that I need to develop a small portion of for mobile devices. For reasons that are not in the scope of this entry - I am using the Microsoft platform and tools - VS2008, ASP.Net, VB.net, .Net AJAX Framework, jquery. I have 2 questions: What is the best page size (Height and Width - mostly width) to m...

How to Add a Many-To-Many Relation in Entity Framework

I am a newbie. I have been able to Add new entities where there is a One-To-Many Relation. I am having a problem (don't Know how to do it) adding a new Entity when the relation is using Many-To-Many. In my EDM I have: Orgs <Scalar Properties> a. Org_ID (Identity Field) b. OrgName c. OrgDesc <Navigation Properties> Building_orgs_Re...

Get name of inheriting class

In the below mockup, how do I find out, if I am an instance of FooDAL or WeeDAL from within the method DoMagix()? Public MustInherit Class DataAccessClass Public Sub DoMagix() '** LOOK AT ME!!! ** 'Who am I? Why am I here? Where am I going? '** /LOOK AT ME!!! ** End Sub End Class Public Class FooDAL ...

VB.NET Image array using project resources

I need to make an array of images using references to the resources folder. The following is my code which does not work: Dim imgPictures(8) As Image imgPictures(0) = Image.FromFile(My.Resources.cat_1.ToString) How do I reference the images sitting in the resouces folder for this task? Cheers ...

Concerned with writing xml

hi guys I have a mail application. While sending to each recipient I am writing to an XML file named mail.xml. I use the following code: Dim from As String = txtFrom.Text Dim txto As String = txtTo.Text Dim subj As String = txtSubject.Text Dim body As String = txtBody.Text Dim settings As New XmlWriterSettings() settings.Indent = T...

What is the difference between = and :=

I'm sure this is straightforward but I cannot find the correct string to get a google result. In VB.NET what is the difference between = (equals sign) and := (colon followed by equals sign)? ...

How can I find out when a new UIElement is added in Silverlight

I am designing a user control in sliverlight that inherits from canvas. It is necessary for me to find out when a new UIELement is added to Children property of MyBase but there is no event like "ItemAdded". Since I want to animate the children of my canvas, I can not use LayoutUpdated event (It is hit a million times). ...

How do I insert an image name into a database?

I succeed to upload and image and resize it. Now I want to insert my image's name into the database. I'm using SQL Server. The table is named images and has two columns, an integer imageid and imagename as string(invarchar(max)). I need the file name saved in the imagename column and imageid must be an identity. Here's the code I have ...

Can i make a DLL file auto run and keep working?

I just saw in some wordpress plugins, there are auto tag plugin, auto RSS fetch, just you install the plugin and it keep working for ever without calling it. What i want to do is to put a dll file inside my Images folder and it will monitor the uploaded files and edit them based on some options, i want this dll to work automatically just...

Changing my Repeater DataSource when there are no items.

I want to place a image with the text "NO IMAGE" in my Repeater when there is no image. What changes must i make in order to achieve this? I want my Repeater datasource to point to an image inside my IMAGE folder in my root directory. My Page Load If Not IsPostBack Then Dim sBasePath As String = System.Web.HttpContext....

VB.net 2008 Property Array

Hi can anyone help here? I am currently learning VB.net but for a project I need to create and array and pass it using a property. The data to be passed will be a train's destination, the time its due and the expected time of the train. I was wondering if someone could simplly explain how to first produce an array and then show how to pa...

If (fileUpload.HasFile)=false

hi all here the code then i will explain my question:- Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click If (IsPostBack) Then HandleUploadedFile() Dim savePath As String = "Images\" If (fileUpload.HasFile) Then Dim fileName As String = file...