I finally figure out how to do this. Unfortunately the technical writers were out to lunch when the tried to explain this. Here is my explanation on how to accomplish this in ASP.NET 3.5:
http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx
Install the MSI.
Add (under the other Imports), the <Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets" />](without []) line to the "MyProject.csproj" file (NOT the user project file, but the one without an extension on Vista) where MyProject is your Web Application Project name.
Add an App_Code folder to your project.
Add the WebProfile.cs file (rt. clicking folder and add existing item)
Rt. click the WebProfile.cs file and click properties.
Change its Build Action from Content to Compile.
Add the profile tags to the web.config file: e.g.
Now you are set. Just make a call to your Profile by setting up this method:
public static WebProfile Profile
{
//get { return new WebProfile(HttpContext.Current.Profile); }
get { return WebProfile.Current; }
}
It should be noted that when you change the Profile, you will need to remove the class from the App_Code and add the newly generated WebProfile.cs class as before.
Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.
Tuesday, August 25, 2009
Sunday, August 23, 2009
How to disable Internet Explorer 8 From Installing With Automatic Updates
To disable Internet Explorer 8 From Installing With Automatic Updates follow these directions:
Download the file from the link below and run.
References:
Download the file from the link below and run.
References:
Saturday, August 15, 2009
Use log4net to Log Errors or Visitors
log4net is a free utility that can be used for logging data about errors or visitors. It is available here: http://logging.apache.org/log4net/index.html
Here is an introductory article: http://www.codeproject.com/KB/trace/Log4Net_with_ASP_NET.aspx
I think a useful way to track users is to log users by their IP Address. Once your log4net is installed correctly, the following code in the Page_Load event can be used to write IP Addresses to a file placed in the App_Code folder (where it is not public):
I'll include the BasePage for a reference to the log variable above (which the System.Web.Page inherits from):
References: http://www.aspxcode.net/free-asp-net-sample-source-code-c.aspx?Topics=how%20to%20get%20the%20IP%20Address%20of%20the%20Visitor
Here is an introductory article: http://www.codeproject.com/KB/trace/Log4Net_with_ASP_NET.aspx
I think a useful way to track users is to log users by their IP Address. Once your log4net is installed correctly, the following code in the Page_Load event can be used to write IP Addresses to a file placed in the App_Code folder (where it is not public):
if (!Page.IsPostBack)
{
string nowip;
nowip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (nowip == null)
{
nowip = Request.ServerVariables["REMOTE_ADDR"];
}
log.Info("Visitor IP: " + nowip);
}
I'll include the BasePage for a reference to the log variable above (which the System.Web.Page inherits from):
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using log4net;
public class BasePage : System.Web.UI.Page
{
public static readonly ILog log = LogManager.GetLogger("Logger");
public BasePage()
{
initLog4Net();
//logAll();
}
/// <summary>
/// initializes Log4Net
/// Described at http://www.codeproject.com/KB/trace/Log4Net_with_ASP_NET.aspx
/// configured in web.config
/// level value can be ALL ERROR DEBUG FATAL DEBUG OFF WARN
/// </summary>
private void initLog4Net()
{
log4net.Config.XmlConfigurator.Configure();
}
/// <summary>
/// test log4net
/// </summary>
protected void logAllTest()
{
bool isDebugEnabled = log.IsDebugEnabled;
bool isErrorEnabled = log.IsErrorEnabled;
bool isFatalEnabled = log.IsFatalEnabled;
bool isInfoEnabled = log.IsInfoEnabled;
bool isWarnEnabled = log.IsWarnEnabled;
log.Debug("Debug msg");
log.Error("Error msg");
log.Fatal("Fatal msg");
log.Info("Info msg");
log.Warn("Warn msg");
}
}
References: http://www.aspxcode.net/free-asp-net-sample-source-code-c.aspx?Topics=how%20to%20get%20the%20IP%20Address%20of%20the%20Visitor
Sample SQLServer Databases
2005 and 2008 Sample SQLServer Databases are available here: MSFTDBProdSamples
Northwind and pubs databases are available here: Northwind and pubs
These are useful for testing .NET Data objects by using SQLDatasource as the DataSource.
Northwind and pubs databases are available here: Northwind and pubs
These are useful for testing .NET Data objects by using SQLDatasource as the DataSource.
Highlight Rows in a GridView
To highlight rows in a GridView you will want to use the GridView DataBound event to add the onmouseover and onmouseout attributes. While CSS methods may work in FireFox browsers, they do not work in Internet Explorer. For the associated javascript method, you can directly set it with this.style.backgroundColor, but this is inflexible. Instead, change the CSS class.
Here is the CSS for the highlighted and normal row (see reference for source of the simple CSS):
Here is the CodeBehind for the GridView DataBound event:
Further modifications for multiple class rows can be made by checking the original CssClass (or checking implicitly by rowCount%currentRow for alternating rows) in the CodeBehind and setting the onmouseout event to switch back to that original class. Another example where this may be necessary is with check box rows that can be selected.
References:
Here is the CSS for the highlighted and normal row (see reference for source of the simple CSS):
<style type="text/css">
.normalRow
{
background-color:white;/* You can update the background Color to normal Gridview Back Color */
cursor:pointer;/* You can change cursor pointer to default, Pointer etc */
}
.highlightRow
{
background-color:Gray;/* You can change the background Color of the row to whatever color you want. You can also give Hexadecimal color code also */
cursor:pointer;/* You can change cursor pointer to default, Pointer etc */
}
</style>
Here is the CodeBehind for the GridView DataBound event:
protected void GridView1_DataBound(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
row.Attributes.Add("onmouseout", "this.className='normalRow'");
row.Attributes.Add("onmouseover", "this.className='highlightRow'");
}
}
}
Further modifications for multiple class rows can be made by checking the original CssClass (or checking implicitly by rowCount%currentRow for alternating rows) in the CodeBehind and setting the onmouseout event to switch back to that original class. Another example where this may be necessary is with check box rows that can be selected.
References:
Rid Grid Lines or Borders in a GridView
Here is how to get rid of Grid lines or borders in a GridView:
References: http://forums.asp.net/t/1134618.aspx
<asp:GridView ID="GridView1" GridLines=None runat="server">
</asp:GridView>
References: http://forums.asp.net/t/1134618.aspx
What are VB Me and MyBase Equivalents in C#?
What are VB Me and MyBase Equivalents in C#?
VB | C# |
Me | this |
MyBase | base |
Subscribe to:
Posts (Atom)