Sunday, October 15, 2006

Code to parse Html to find value of a Input control using Regular Expression

Here's the code to parse html and find the value in input control. some times .net developers come across a situation where we need to parse the html and find the value in a input control. This code uses regular expression to find the value.

Function
------------
Public Function FindControlValue(ByVal InputHtml As String, ByVal ControlName As String, ByVal ValuePattern As String) As String
Dim reg As String = ""
Dim m1, m2 As Match
Dim options As RegexOptions = RegexOptions.Multiline
Dim matches1, matches2 As MatchCollection
matches1 = Regex.Matches(InputHtml.Replace("""", "'").ToString, reg, options)
For Each m1 In matches1
reg = ValuePattern
matches2 = Regex.Matches(m1.Value, reg, options)
For Each m2 In matches2
Return m2.Value.Replace("'", "").ToString
Next
Next
Return ""
End Function


You can call the function like,

if your input control value is string then
FindControlValue(HtmlResult, "StringControlName", "'\d+'")

if your Input control value is Number then
FindControlValue(htmlResult, "NumericControlName", "'\d+'")

if your Input control value is decimal then
FindControlValue(HtmlResult, "DecimalControlName", "'(\-?\d+\.\d+)'")

Hope this code helpful to some one who surfing my blog.

Happy Coding.

Friday, October 13, 2006

Google Office Vs Ms Office

Google finally made a right step towards web based office suit. they opened the site http://docs.google.com/ Here you can create your own office documents and worksheets. you can share the documents with your friends. That means many people can work with the same document at the same time. you can save the file in web itself. so you can work with your documents any where you go. cool stuff. Even you can save the docuemnts in pdf,doc in all other formats.

Now MsOffice Word => google document
MsOffice Excell => Google worksheet
MsOutlook => Gmail
MSPowerpoint => only Piccassa now (windows based) hope soon web based tool.
Ms Messegner => gmail talk.

Lets see what Microsoft is going to do. I heared Ms offfice is trying for web based live office. Lets wait and see who win the race!!!

Wednesday, October 04, 2006

Google open Gadgets for your webpage.

Google today made all gadgets available for websites. you can now add any one of the google gadget to your website. cool move by google. let me add one gadget here. you can add more gadgets from here.