another vbscript "cheat"

by Jesse 23. June 2008 07:08

I hate putting text boxes and labels on an aspx page.  It's stupid boring and that trigger in my brain says "There's GOT to be a faster way to do this" ...and now there is, I got sick of it so I made a vb script as such...

DIM fso, outputFile

const ForAppending = 8
dim LabelStart, TextBoxStart
LabelStart = "<asp:Label runat=" & chr(34) & "server" & chr(34) & " ID=" & chr(34) & "lbl"
TextBoxStart = "<asp:TextBox runat=" & chr(34) & "server" & chr(34) & " ID=" & chr(34) & "txt"

'variables we will need
dim controlName, labelText
dim keepAdding, intVal
keepAdding = True
Set fso = CreateObject("Scripting.FileSystemObject")
Set outputFile = fso.OpenTextFile("ControlGenerator.txt", ForAppending, True)
do while keepAdding

 controlName = InputBox("ControlName?")
 labelText = InputBox("Label Text?")

 outputFile.WriteLine(LabelStart & controlName & chr(34 & " Text=" & chr(34) & labelText & chr(34) & "/>")
 outputFile.WriteLine(TextBoxStart & controlName & chr(34) & "/><br />" )
 intVal = MsgBox("Add Another?", 4)
 if (intval = 7) then keepAdding = false
loop
outputFile.Close
wscript.echo("Complete")
 

Save that as a vbs file.  What will this do?

<asp:Label runat="server" ID="lblStreetName" Text="Street : "/>
<asp:TextBox runat="server" ID="txtStreetName"/><br />

Now to go pound out 40 or so controls like this....no, not joking.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Like the description says, at my core, I'm a scientist and engineer.  I came from humble beginnings on a 486DX2 Packard Hell playing doom2 on IPX to in a small time retail shop and got into hardware (ISO layers FTW!) and it was all downhill from there.  I'm infinitely curious about almost everything and always wanting to know.

Some of the stuff I'm currently into/researching...

Sitefinity

Ninject

Subsonic

Java

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's, their brother nor their dog's view in anyway.  At all.  Ever.

© Copyright 2007-2008