Checking whether value is entered into a control and preventing focus to go out if no value is entered.
Checking whether value is entered into a control and preventing focus to go out if no value is entered.
EventViewer can be accessed by Selecting Event Viewer from Administrative Tools of Control Panel. This code snippet will add an Entry called Shalvin inside the Application section.
Uploading a file to a specific folder inside the virtual directory.
aspnet_regsql is a tool user for installing membership, role and personalization tables to Sql Server.
1. Porting all tables to Sql Server
2. Porting only membership tables to Sql Server
3. Removing all membership and role tables
4. Removing Personalization tables.
I am be posting a detailed blog on Membership in shalvinpd.blogspot.com soon.
Happy programming
Web site Administration Tool is accessible only from the hosting server. Many times programmers won't have direct access to the the hosting server. So knowledge of ASP.Net Membership classes is an added advantage in creating an administrative module for the site.
In this code snippet we will take up:
1. Listing all roles
2. Creating a role
3. Listing all users
4. Deleting a user
5. Listing Number of users online
CAS is the programatically means by which you secure the resouce of a system like file system, printer, registry, etc. in contrast to Role Base Security (RBS)
Placing ComboxBox in DataGrid Cell is a task usually found in Invoicing application. Here is my version of same.
Serialization is the process of saving the state of an object into persistant medium.
BinaryFormatter class is used for serializing and deserializing an object.
HybridDictionary is optimized for key-based item retrieval from both small and large collections.
Though .Net classes are vast and versatile at time you will have to resort to Win32 API calls for accomplishing certain tasks.
The following code shows a simple example of invoking a Win32 api.
The best way to use Win32 apis is to encapsulate it in a class module.
The namespace for COM interop is System.Runtime.InteropServices.
The method name should have DllImport attribute specifying the name of the dll. Here the dll is user32. Other dlls are Gdi and Kernel.
TreeView was one of my favourite control in COM. It is well suited for creating Chart of Accounts, Hierarchical data and the like. Though there is a tree view in .Net I find it less flexible in comparison to COM TreeView.
The issue with using COM TreeView in C# is C# does not support optional parameters. Type.Missing it the way out.
But how to do the same in C#. For instance :
int hits = Int32.Parse(Application["Hits"]);
Will create a error
Error 2 Argument '1': cannot convert from 'object' to 'string' E:\Sh\ASP\cS HitCounter\Global.asax 26 32 E:\...\cS HitCounter\
ok I used the global.asax page for this one, got this information off www.4guysfromrolla.com, good site.
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)'This variable Hits will store the # of visitors
Application("Hits") = 0
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
'Lock the Application for concurrency issues
Application.Lock()
'Increment the counter
Application("Hits") = Application("Hits") + 1
'Unlock the Application
Application.UnLock()
End Sub
Now to declare it in my webform...
This page has been viewed
<%=application("Hits")%>
times.Ok guys, this works but I would not by any means recommend it because it resests itself every time you rebuild the project, plus it resets whenever the server your site is on reboots or restarts, if anyone has a better alternative to this, please let me know. The next question I have is how do I replace the number on the hit counter, with a graphic, say it said 2 people have visited the page in plain text, I want that "2" to be an image of a 2, I've found a little on this but it's not working. Will post back if I find anything out.