Mar 19, 2010
Mar 14, 2009
Feb 21, 2008
Dim messageList As ArrayList = New ArrayList()
If (pageType <> PageType.Search) Then ' Add/Edit Validation
Dim fullName As TextBox = TryCast(control.FindControl("fullName"), TextBox)
If (fullName IsNot Nothing) Then
If (Not DataFormat.CheckString(fullName.Text)) Then
messageList.Add("Invalid Value (String): fullName")
Dim phoneNumber As TextBox = TryCast(control.FindControl("phoneNumber"), TextBox)
If (phoneNumber IsNot Nothing) Then
If (Not DataFormat.CheckInt32(phoneNumber.Text)) Then
messageList.Add("Invalid Value (Int32): Phone Number")
Return IIf(messageList.Count = 0, Nothing, messageList)
' Powerful TIPs !
Dim source As WebControl = TryCast(sender, WebControl)
Protected Sub Page_Load(ByVal s As Object, ByVal e As System.EventArgs)
' Cache Setting, I just know about
' ASP Caching can be set manually on the virtual directory property
' Auto-find control and set focus to it;
' I just know got such a syntax, which really near to human language syntax "IsNot"
' and about ClientID property which is very useful in some case.
If (tblpwdDetailsView.FindControl("fullName") IsNot Nothing) Then
Page.Form.DefaultFocus = tblpwdDetailsView.FindControl("fullName").ClientID
' The way they check for QueryString exist or not
If (Not Page.IsPostBack) Then
If (Request.QueryString.Count > 0) Then
Jan 2, 2008
Error: The component 'myCOM.COMClass' cannot be created. Apartment threaded components can only be created on pages with an <%@ Page aspcompat=true %> page directive.System.Web
The error above noted that we need to add page directive aspcompat = true because you are using COM interop with ASP.NET pages.
Just simply add the page directive "aspcompat=true" and it solved! :)
I was thinking what's wrong with this line and you will get this exception if you throw the exception out to the display only.
Surfing around and I got the answer.
We have to understand how response.write or server.transfer work!
In ASP.NET, response.write and server.transfer will end the threading with response.end.
Thus, if we have a TRY...CATCH...END TRY within it, the TRY Thread will be aborted and ended suddenly and the exception will be caught.
We should make the response.redirect before or outside the catch at this point.
Usually, we will have a checking for session lost at the beginning of the page.
If String.IsNullOrEmpty(Session("user_id")) Then
This simple validation portion might not need to be inside Try Catch loop and you will be safe!
In addition, sometimes programming like to declare variable inside Try Catch loop too, and it is NOT necessary to do so.
A simple statement likes
Dim myString as stringis NOT necessary to be in Try Catch loop. :)
Nov 8, 2007
Wooow, just surf around for free datagrid in WPF, I got this Xceed.
Xceed Component Demo
Doesn't it look pro ?
I am not Xceed stuff, anyway feel amazed with the little visual effects and design in this rich media web application.
Take a look! Wish to explore it more and hope I can apply my macromedia flash skill into this WPF too!
You have to get your Google API Key first!
Nov 1, 2007
Here is some code to do it.
Lets say the current page is simply "http://www.mysite,com/view_user.asp"
This is all you need to get you the current page URL
Thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL")
Now, if your page has Querystring info and variables you want as well.
Like so "http://www.mysite,com/view_user.asp?ID=1&Name=Fred"
you would use code like this.
Thispage ="http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring
If your page had Form info that might have been posted to it you would use code like this.
Thispage = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Form
If your page had both Querystring and Form info you could try code like this.
Thispage = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") & "?" & Request.Querystring & Request.Form
Oct 30, 2007
sPath = Server.MapPath("Moozik\")
fRoot = oFSO.GetFolder(sPath)
(web paths, not full physical)
My file: /Test/Myfile.aspx
Virtual directory: /Test/VirtualDir/
or if you are in a higher directory:
You are probably just getting the virtual path (the one that gets sent into
Oct 29, 2007
1. add in a list.
2. add in table
3. drag data from data source to table
Dim voucher As New Voucher
DataGridView1.DataSource = voucher.FillVoucherHeader
DataGridView2.DataSource = voucher.FillVoucherItems
DataGridView3.DataSource = voucher.FillVoucherTotal
Just recall back Java Learning during university lab.
From the Start menu, click on the Accessories folder, and then open the Windows Command Prompt.
At the command line, type vbc.exe /imports:Microsoft.VisualBasic,System sourceFileName and then press ENTER.
For example, if you stored your source code in a directory called SourceFiles, you would open the Command Prompt and type cd SourceFiles to change to that directory. If the directory contained a source file named Source.vb, you could compile it by typing vbc.exe /imports:Microsoft.VisualBasic,System Source.vb.
- To compile with reference file:
Oct 18, 2007
Web.config configuration files and app.config project item files, which get converted to "ExecutableName.exe.config" at build time, both support the convenient appSettings section with its own read method in the System.Configuration.ConfigurationSettngs class. The appSettings section stores element name / value pairs in the format:
You can store as many of these
I often read out my appSetting values into a NameValueCollection at runtime, which provides one-shot acess to the entire collection in memory:
NameValueCollection mySettings = System.Configuration.ConfigurationSettings.AppSettings;
string connStr = mySettings["connString"];
But what about being able to change, add, and save appSettings items while that app is running in response to user input or other actions, instead of just reading them out? Nada, Zippo, Efes! You have to open the config file manually and add them by "hand". Well that kinda stinks, don't you think? So here's my take on a convenient little class that allows you to either modify, add or delete any appSettings element, in either your Executable, Console or ASP.NET web application at runtime, on the fly. Bear in mind of course, that if you modify a web.config on a running ASP.NET app, the ASP.NET worker process will recycle. Users currently using your app aren't exactly guaranteed to have a fun experience when this happens...Original Source: http://www.eggheadcafe.com/articles/20030907.asp
By Peter A. Bromberg, Ph.D.