Shalvin Newbie Poster

Checking whether value is entered into a control and preventing focus to go out if no value is entered.

Shalvin Newbie Poster

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.

Shalvin Newbie Poster

Uploading a file to a specific folder inside the virtual directory.

Shalvin Newbie Poster

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

Shalvin Newbie Poster

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

Shalvin Newbie Poster

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)

Shalvin Newbie Poster

Placing ComboxBox in DataGrid Cell is a task usually found in Invoicing application. Here is my version of same.

Shalvin Newbie Poster

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.

Shalvin Newbie Poster

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.

Shalvin Newbie Poster

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.

Shalvin

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\

[B][/B][COLOR=#0000ff][COLOR=#0000ff][/COLOR][B]
[/B][/COLOR][B][/B]
[quote=Slade;23579]ok I used the global.asax page for this one, got this information off [URL="http://www.4guysfromrolla.com"]www.4guysfromrolla.com[/URL], good site.

[COLOR=#0000ff]Sub[/COLOR] Application_Start([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Object[/COLOR], [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] EventArgs)

[COLOR=#008000]'This variable Hits will store the # of visitors[/COLOR]

Application("Hits") = 0

[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR]

[COLOR=#0000ff]Sub[/COLOR] Session_Start([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Object[/COLOR], [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] EventArgs)

[COLOR=#008000]'Lock the Application for concurrency issues[/COLOR]

Application.Lock()

[COLOR=#008000]'Increment the counter[/COLOR]

Application("Hits") = Application("Hits") + 1

[COLOR=#008000]'Unlock the Application[/COLOR]

Application.UnLock()

[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR]

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.[/quote]