vb.net

Configurable Columns in ASP.NET

Does anyone have a suggestions as to the best way to allow users to select which columns appear in a datagrid? I would like them to be able to set this up. It would be stored with the user in a profile and loaded each time the user loads the grid. I was thinking about something with ASP.NET personalization. ...

How does reflection tell me when a property is hiding an inherited member with the 'new' keyword?

So if I have: public class ChildClass : BaseClass { public new virtual string TempProperty { get; set; } } public class BaseClass { public virtual string TempProperty { get; set; } } How can I use reflection to see that ChildClass is hiding the Base implementation of TempProperty? I'd like the answer to be agnostic between c...

How to display a non-breaking space with VB's inline XML

I am using VB9's inline XML, and I have a need to specify a non-breaking space. Where you would normally use " " in html, using it in inline XML produces the "XML entity references are not supported" error. How do you specify a non-breaking space? ...

Unpacking _WTS_CLIENT_ADDRESS.Address in vb.net (retreiving IP address from Terminal Services Client)

I have the following structure: <StructLayout(LayoutKind.Sequential)> _ Public Structure _WTS_CLIENT_ADDRESS Public AddressFamily As Integer <MarshalAs(UnmanagedType.ByValArray, SizeConst:=20)> _ Public Address() As Byte End Structure Which is populated by the following call: Dim _ClientIPA...

Encapsulation VS Inheritance - How to use a protected function?

In OOP languages like C# or VB.NET, if I make the properties or functions in a super class protected I can't access then in my Form, They can only be access in my class that inherits from that super class. To access those properties or functions I need to make them public which defeats encapsulation on re-write them in my class which de...

Why Type.Equals(t1, t2) and not the equality operator?

Why must Type.Equals(t1, t2) be used to determine equivalent types, and not the equality operator (e.g. for VB.NET, t1 = t2)? It seems inconsistent with other parts of the .NET API. Example in VB.NET: If GetType(String) = GetType(String) Then Debug.Print("The same, of course") End If causes a compile-time error of "Operator '=...

Rendering Excel from browser

Hi, I have some content that i have to render as a excel file in browser. I was able to render a grid content to excel with the below code. Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.xls"; System.IO.StringWrite...

Does VB.NET optimize the concatenation of string literals?

Similar to this question, but for VB.NET since I learned this is a language thing. For instance, would the compiler know to translate Dim s As String = "test " + "this " + "function" to Dim s As String = "test this function" and thus avoid the performance hit with the string concatenation? ...

Set ASP:ContentPlaceHolder Content Programatically

What is the easiest way to set the contents of an <asp:ContentPlaceHolder> programatically? I imagine ill have to do a Master.FindControl call? ...

How to declare an array inline in VB.NET

I am looking for the VB.NET equivalent of var strings = new string[] {"abc", "def", "ghi"}; ...

Date Comparison in Dynamic Where Clause in Linq Gives Overload Exception

I'm trying to inject a dynamic where clause in my Linq to SQL query and I get an overload exception. The same expression work when added in the query proper? qry.Where(Function(c) c.CallDate < Date.Now.AddDays(-1)) Any thoughts on how to this to work? The exception reads: Overload resolution failed because no accessible 'Where' ca...

Raising Events from a thread safely

I am having some problems with events being raised from the non-UI thread, in that i dont wish to have to handle the If me.invokerequired on every event handler added to the thread in Form1. I am sure i have read somewhere how to use a delegate event (on SO) but i am unable to find it. Public Class Form1 Private WithEvents _to As ...

Default properties in VB.Net?

In the early days of .Net, I believe there was an attribute you could decorate a class with to specify a default property. According to some articles I've found, this appears to have been yanked from the framework at some point because it was a little confusing, and I can see how that is the case. Still, is there another way to get th...

C# to VB.NET help

I have moved from C# to 9-5pm VB.NET Any tricks i should know? Where does VB.NET differ the most apart from syntax? Where have namespaces gone? [Note: just found http://converter.telerik.com/ brilliant] Cheers John ...

Regular expression to convert substring to link

Hi, i need a Regular Expression to convert a a string to a link.i wrote something but it doesnt work in asp.net.i couldnt solve and i am new in Regular Expression.This function converts (bkz: string) to (bkz: show.aspx?td=string) Dim pattern As String = "&lt;bkz[a-z0-9$-$&-&.-.ö-öı-ış-şç-çğ-ğü-ü\s]+)&gt;" Dim regex As New Regex(pattern...

Design question with Enums to model Type relationships

In designing a class for customer for example would it make sense to use an Enum for CustomerType? ...

New {object} vs {object} = new {object}

I was just wondering if there is any difference between the two different new object initializers or is it just syntactic sugar. So is: Dim _StreamReader as New Streamreader(mystream) and different to: Dim _StreamReader as Streamreader = new streamreader(mystream) Is there any difference under the hood? or are they both the sam...

Unit Testing and VB.NET

Where can I find either literature or video demonstration of unit testing applications using VB.NET? As a novice/hobbyist programmer I would like to build a solid foundation in developing applications using the unit testing methodology. ...

Handling an open file when trying File.Move()

Is this the best way to handle file moving in a windows service? we have many files that get matched and moved, but an end user may have the file opened at the time of moving. This is what the code currently says: Do While IO.File.Exists(OriginalFilePath) Try IO.File.Move(OriginalFilePath, BestMatchPath) Catch ex As IO.IO...

Input Values for Nativemethods.GetSystemMetrics Function in .Net

This function appears to be a way to access all sorts of system values. For example nativemethods.GetSystemMetrics(4096) returns whether a session is remote or local. All I can find on the web are specific examples--does anyone know where I could find a complete list of input parameter values/what they return? Seems that it could be v...