Tim Maxey .NET Technology Blog & Resources

VB.NET Code

Posts about VB code

Could not find stored procedure

I haven't had to use a direct call to a stored procedure in a long time, but came across the could not find stored procedure error. (And yes I had all security set fine). If I uncommented out the "commandType" it worked! Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("myconnection").ConnectionString)         Dim cmd As New SqlCommand         Dim execStr As String = "EXEC dbo.InsertActivity " & userid         cmd.CommandText = execStr         'cmd.CommandType = CommandType.StoredProcedure DOES NOT WORK WITH THIS UNCOMMENTED, WEIRD         cmd.Connection = conn         conn.Open()         cmd.ExecuteNonQuery()         conn.Close()         cmd.Dispose()

RegEx RegEx.Replace Regular Expressions Explained

Ok, gonna try to explain this, for me and for you: I needed to strip apart a strap number like U-22-29-5J5-0000.20 and pass it to the property appraiser's site like: 29225J5000020U Now how do you do that? You have to use Regular Expression Replace, so pattern the above like this: ([0-9a-zA-Z]{1})([\w-]{1})([0-9a-zA-Z]{2})([\w-]{1})([0-9a-zA-Z]{2})([\w-]{1})([0-9a-zA-Z]{3})([\w-]{1})([0-9a-zA-Z]{4})([\w.]{1})([0-9a-zA-Z]{2}) Say what? huh? Let's break it apart. The above regex is the "pattern" to look for, so we are matching in the first () i.e. ([0-9a-zA-Z]{1}) all numbers and letters. Note: each character in the orginal strap is represented by "something" in parentheses () This first set ([0-9a-zA-Z]{1}) is the "U" notice the [...

Disable hide ASP.NET button after submit click

Here is the easiest way to hide or rather disable the asp.net button control, or any other control for that matter, take this: <div id="dwait" style="display:none">please wait, creating account...</div> <div id="dBut"><asp:Button ID="Button1" runat="server" Text="Submit" OnClientClick="HideMe();" /></div> function HideMe() { var dw = document.getElementById("dwait"); var db = document.getElementById("dBut"); db.style.display = "none"; dw.style.display ="block"; } When the asp.net button is clicked, it just hides the div of the button, or imagebutton (if you want) and shows the "wait" div. In the wait div you could put/style it however, like with an animated waiting or whatever... Enjoy! 

Plat Maps Plot Maps Parcel Boundaries

A new service was just release (BETA) for Florida county plat maps, Florida county plot maps, Florida county parcel boundary maps. Really cool application. Check it out: Florida County Plat, Plot, Zoning, Parcel Boundary Maps Technologies used: Google Earth Plugin, KML, Google Maps, Mobile device support for Android and iPhone platforms. Search the entire state of Florida for parcel boundaries, owner information, Google Street View, etc...

Javascript select ASP.NET Checkboxlist items

Ok I needed a function that would select certain CheckBoxList items of an ASP.NET CheckBoxList, so here it is, hope is helps someone else out! if you want I use this function hightlight the item in yellow: function uStyle(cb) {    cb.parentNode.style.backgroundColor = cb.checked ? "yellow" : "";    cb.parentNode.style.color = cb.checked ? "blue" : ""; } function doCertainOnes(cbControl) {     var chkBoxList = document.getElementById(cbControl);     var chkBoxCount = chkBoxList.getElementsByTagName("input");     chkBoxCount[5].checked = true;     chkBoxCount[5].focus();    //GOING TO JUMP DOWN IN THE LIST TO THE FIRST SELECTED            uStyle(chkBoxCount[5]);     chkBoxCount[6].checked = true;     uStyle(chkBoxCount[6]);     chkBoxCount[7].checked = true;     uStyle(chkBoxCount[7]);      for (var i = 10; i < 50; i++) {        chkBoxCount[i].checked = true;        uStyle(chkBoxCount[i]);    ...

ASP.NET cookie auto log in

Ok it is NEVER a good idea to store a cookie on a client's machine with an ID or username and password in the cookie. Can steal the cookie. Come on, cookies are good to eat, chocolate chip cookies are my fav! Anyway, take a look at this, I think joomla does this and I don't take all the credit, but this works great: 1. Obviously a login.aspx page with a checkbox to save my login. 2. Evertime the user is logged in, either themselves or through the cookie, it deletes the old one in the table and writes a new one...

WebForm_DoPostBackWithOptions vs __doPostback

Hi there guys, had an issue with WebForm_DoPostBackWithOptions vs __doPostback. WebForm_DoPostBackWithOptions started showing up on a page and not showing up on other .NET pages. It was a pain in my butt! Because WebForm_DoPostBackWithOptions wasn't working, all my linkbutton had this javascript function rendered and none of the events were firing! So after looking around I found out that I had some panels that were hidden on the page. And in one of those panels, I have a validation control, if a validation control is "hidden" on the page (the panel's visibility is set to false and later made visible) then...

Webservice error on the server, but not my local box

My webservice call to, example: service1.asmx/myfunction just wasn't working on the server, but on my local box it worked great, so I had to add entries in the web config... This needs to go between your <system.web> tags in the web.config <webServices>     <protocols>         <add name="HttpGet"/>         <add name="HttpPost"/>     </protocols> </webServices>

Birthday diplayed as age .NET, ASP.NET, VB.NET

I needed to display the age of of a birthday field from a database. I was so tired of coding and came across this function! I got this from a guy named "hans" on a forum, great little function I didn't have to write! Private Function Age(ByVal Birthday As DateTime) As Integer Dim year As Integer = Today.Year - Birthday.Year If Today.Month < Birthday.Month Or (Today.Month = Birthday.Month And Today.Day < Birthday.Day) Then Return year - 1 Else Return year End If End Function

VS 2008 keeps asking to replace AjaxControlToolkit.dll

I had an ANNOYING problem with Visual Studio 2008 and the AjaxControlToolkit.dll. Seemed like if I had an Update Panel on the aspx age, I would get asked if I wanted to replace the AjaxControlToolkit.dll. ANNNOYING, so I did some searching and finally did this: 1. In VS 2008 I had to right click on the toolbar and choose the option "choose items," then I sorted the the .NET Framework Components and unchecked the AjaxControlToolkit version version 3.0.1xxx and keep the 3.0.2xxx. 2. Next I went to the property page of the project and references and removed the AjaxControlToolkit reference, then I...

Full VB.NET Code Archive