Jan 12 2006

Visual Studio .NET and Class Libraries

Category: ASP.NET 1.x | ASP.NET 2.0 - GeneralBil@l @ 04:31

When I start a new project, I usually create a Blank Solution in VS.NET, then add to it my Class Libraries and Web Application. The problem I used to have before is that, every time I did some changes in one of the Class Libraries I had to update the references manually to all other projects referencing that updated Class Libraries.

Thank to Peter Johnson for hinting for me that:

Correct way:
1. Right-click web project file, choose "Add Reference..."
2. Click "Projects" tab.
3. Select your class library project and hit OK.

Wrong way:
1. Right-click web project file, choose "Add Reference..."
2. On ".NET" or "Browse" or "Recent" tabs, choose your class library output DLL.

Hope that helps you out.

This way, whenever you change anything in your Class Libraries, then you do a Build, all the references will be updated.

Regards

 

Tags: ,

Jan 6 2006

Visual Studio 2003 + HTTP/1.1 403 Forbidden

Category: ASP.NET 1.xBil@l @ 19:07

Before I create a new web application in Visual Studio .NET 2003, I usually create a new website in IIS MMC, then create the new web application based on the url of teh website I created early.

Today, doing the same process as above generated the following error:

The web server reported the following error when attempting to create or open the Web Project located at  the following URL: '....' . 'HTTP/1.1 403 Forbidden'

If you ever face such a problem, make sure in the website's properties screen in IIS MMC, in the Home Directory Tab, Execute Permissions is 'Script Only', since by default it will be 'None'.

Regards

Tags:

Jan 5 2006

Microsoft VPC 2004

Category:Bil@l @ 23:56

Hello:

I just finished now configuring my laptop to function as follows:

My laptop is a toshiba Satellite M45 Series. The host operating system is Windows XP + SP2.

I have created a Virtual PC with the guest operating system as Windows 2003 Standard Server and installed on it most of the development tools I use, including:

Visual Studio 2003 + Visual Studio 2005 + MS SqlServer 2000 + FireWorks MX 2004 + IE 6.0 + FireFox 1.0 + MS Front Page 2003

Then I backed-up the new VPC which is around 7GB to an external HardDisk.

I will now format my host machine and have a clean installation of WinXP SP2.

This way, whatever happened to my guest machine, the basic tools which usually takes like 6 or 7 hours to be installed will be preserved now.

You can also, create a VPC with any windows installation and keep that VPC as a Base HardDisk, then I can create other VPCs out of that Base HardDisk by inheriting from the base one.

Hope this post helps you out.

Regards.

Tags:

Jan 4 2006

Code Snippets in Visual Studio 2005

Category: ASP.NET 2.0 - GeneralBil@l @ 17:09

I kindly invite you to check my latest article on the www.aspalliance.com, with the title of:

Code Snippets in Visual Studio 2005

Hope you enjoy it.

Regards

Tags:

Jan 3 2006

www.System.Net.Mail

Category: General | GeneralBil@l @ 17:55

My colleague Dave Wanta published his new informative website about System.Net.Mail, the new namspace for email-related issues in ASP.NET 2.0

check at: http://www.systemnetmail.com/

Regards

Tags: ,

Aug 30 2005

Identity Columns in MS SQL Server

Category: Databases & SQLBil@l @ 10:17

When working with Identity Columns in MS SQL Server, and specially when testing your database and inserting some junk data for the sake of testing, you ask yourself, how would I reset my Identity Columns to their original values after I finish testing with the junk data?

dbcc checkident (Table1, reseed, 1)

Hope that helps.

Regards

Tags:

Jul 15 2005

Define an Event Handler for a HyperLink Server Control

Category: ASP.NET 1.x | ASP.NET 2.0 - GeneralBil@l @ 06:55

Hello, a common question on the ASP.NET Forum is:

How to define an Event Handler for a HyperLink?

The solution as follows:

protected System.Web.UI.WebControls.HyperLink HyperLink1;
    
private void Page_Load(object sender, System.EventArgs e)
{
    HyperLink1.Attributes.Add("onClick",
Page.GetPostBackEventReference(this.HyperLink1,"HyperLinkPostBack$"+this.HyperLink1.ID)); if ( (IsPostBack) && (Request.Form["__EVENTTARGET"] != null) && (Request.Form["__EVENTARGUMENT"].ToString().StartsWith("HyperLinkPostBack")) ) { string[] args = Request.Form["__EVENTARGUMENT"].ToString().Split('$'); if ( (string.Compare(args[0], "HyperLinkPostBack", false, System.Globalization.CultureInfo.InvariantCulture) == 0)
&& (args.Length > 1) ) { HyperLinkHandler(args[1].ToString()); } } } public void HyperLinkHandler(string ID) { Response.Write("You clicked HyperLink with ID : "+ ID); }

                
 

                
 
 Or You could use this way, using IPostBackEventHandler:

                
private void Page_Load(object sender, System.EventArgs e)
{
    HyperLink1.Attributes.Add("onClick", Page.GetPostBackEventReference(this, "HyperLinkPostBack" + "$" + this.HyperLink1.ID));
}

public void RaisePostBackEvent(string eventArgument)
{
    if (!string.IsNullOrEmpty(eventArgument))
        {
            string[] args = eventArgument.Split('$');
                if ((string.Compare(args[0], "HyperLinkPostBack", false, System.Globalization.CultureInfo.InvariantCulture) == 0) 
&& (args.Length > 1)) { HyperLinkHandler(args[1].ToString()); } } } public void HyperLinkHandler(string ID) { Response.Write("You clicked HyperLink with ID : " + ID); }

                
 

Hope that helps,

Regards

Tags: ,

Jul 14 2005

Add JavaScript Functionality to GridView

Category: ASP.NET 2.0 - GeneralBil@l @ 19:58

If you want to change the Cursor when the mouse is over the GridView, follow the simple steps below:

protected void RowCreated (object sender, GridViewRowEventArgs e)
{
    e.Row.Attributes.Add("onMouseOver", "this.style.cursor='n-resize'");
}


Hope that helps,

Regards

Tags:

Jul 14 2005

Extend GridView

Category: ASP.NET 2.0 - GeneralBil@l @ 19:43

I want ot point you to two important links on Extending GridView, by Frerik Normen:

1- http://fredrik.nsquared2.com/print.aspx?PostID=186

2- http://fredrik.nsquared2.com/print.aspx?PostID=177

Hope that helps,

Regards

Tags:

Jul 13 2005

TemplateField in GridView

Category: ASP.NET 2.0 - GeneralBil@l @ 23:43

You can call a custom method inside the TemplateField of the GridView as follows:

<TemplateField>
  <ItemTemplate>
      <%# GetSum((int)Eval(“Number1“), (int)Eval(“Number2“)) %>
  </ItemTemplate>
</TemplateField>

public string GetSum(int num1, int num2)
{
     return (num1+num2).ToString();
}

Hope that helps,

Regards

Tags: