Welcome to ASP.NET Guild

Be sure to come back often and tell others. If you have any tips, tricks, examples, please email them to me at chris.williams@techguilds.com and I will post them. Check out our ASP.NET QuickStart and C# QuckStart Libraries. Below is my latest articles.

Monday, November 27, 2006

asp.net caching documentation

Below is a really good link that describes the various caching methods in ASP.NET

http://www.codersource.net/asp_net_caching.aspx

If you have any tips, tricks, articles, sample code that you think will be helpful to other ASP.NET developers email them to me at chrisw_88@hotmail.com and I will post them.

Friday, October 20, 2006

iis redirect wildcards

This link is a more comprehensive link showing the wildcards available

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/41c238b2-1188-488f-bf2d-464383b1bb08.mspx?mfr=true

If you know of any tips, tricks, sample code that you feel will help other ASP.NET developers please email them to me at chrisw_88@hotmail.com and I will post them.

Thursday, October 05, 2006

asp.net 2.0 security

I have had a few emails about securing ASP.NET 2.0 applications so I came across these two links. The first is a FAQ, the second is a step by step way of setting it up for the Microsoft Access provider. The steps are similar for SQL Server you just have to change the provider and create the tables in SQL Server.

ASP.NET Security FAQ

ASP.NET Security setup article

Addison-Wesley - ASP.NET 2.0 Security Article

Tuesday, July 25, 2006

Flash and ASP.NET 2.0 double click issue (Click to activate control)

This issue only started once I upgraded my website from 1.1 to 2.0
It appears that Microsoft released a security fix and this caused it.

The following article will show you a workaround for this. Basically
you are writing the object tag to the page using document.write in a
javascript file. Then calling the script file from the page.

Flash and 2.0 double click issue Link
https://tgaw.wordpress.com/2006/05/02/ms06-013-click-to-activate-and-use-this-control/

There is a free javascript library called swfobject.js that is available on google code that assists in fixing this and other issues with ie and flash.

http://code.google.com/p/swfobject/

If you have any additional tips, tricks etc that you would like me to post
to my blog, please email them to me at chrisw_88@hotmail.com

Monday, July 17, 2006

Flash in a form Fix - Using JavaScript

The fix can be found by following this link but you have to scroll down or do a find for
"briandunnington said on May 9, 2006 at 4:56 PM : "

http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002200.html

Place the following script before the flash object reference and be sure to change ShockwaveFlash1 to your flash file name:

<script type="text/javascript">
function ExternalInterfaceManager()
{
this.registerMovie = function(movieName)
{
if(!window.fakeMovies) window.fakeMovies = new Array();
window.fakeMovies[window.fakeMovies.length] = movieName;
}

this.initialize = function()
{
if(document.all)
{
if(window.fakeMovies)
{
for(i=0;i {
window[window.fakeMovies[i]] = new Object();
}
window.onload = initializeExternalInterface;
}
}
}
}

function initializeExternalInterface()
{
for(i=0;i {
var movieName = window.fakeMovies[i];
var fakeMovie = window[movieName];
var realMovie = document.getElementById(movieName);

for(var method in fakeMovie)
{
realMovie[method] = function() {flashFunction = "<invoke name=\"" + method.toString() + "\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments, 0) + "</invoke>";this.CallFunction(flashFunction);}
}

window[movieName] = realMovie;
}
}

</script>


<script type="">
var eim = new ExternalInterfaceManager();
eim.registerMovie("ShockwaveFlash1");
eim.registerMovie("ShockwaveFlash2");
eim.initialize();
</script>


If you have any tips you would like to share please email them to me at chrisw_88@hotmail.com

Friday, July 14, 2006

.NET Mail Links, FAQ

For people working with the .NET Mail classes, here are a couple links that may
help you diagnose issues.

.NET 2.0

.NET 1.1

If you have any additional links you would like me to add, please email them to me at
chrisw_88@hotmail.com

Tuesday, July 11, 2006

Dropdowns over flash or other controls in IE

Below is a link to some code that may be helpful to you.
Basically the issue is that select controls overlap other
controls and divs regardless of z-order. The solution is
to hide all of them on a page when this issue arises and then
reshow them after you are done with the div or flash.

Hide Select Menus JavaScript: http://www.shawnolson.net/a/1198/

If you have any tips you would like to share please email them to me at chrisw_88@hotmail.com

Tuesday, July 04, 2006

Flash Remoting Links

Below is a list of links related to Flash Remoting:

If you have any more flash remoting links or other tips, tricks, code samples, etc that will help other ASP.NET developers please email them to me at chrisw_88@hotmail.com


Friday, June 30, 2006

Multiple pages accessing the same codebehind file in ASP.NET 2.0

In ASP.NET 1.1 you may have had multiple pages access the same codebehind page, but in ASP.NET 2.0 you get the following ugly message when you try to publish

The type 'xxxx' exists in both '...\v2.0.50727\Temporary\....xxx.dll' and '...\v2.0.50727\Temporary\...yyy.dll'

Rick Strahl's solution to this problem is to do a page reference instead of pointing both to the same source file. Eg. <%@ Reference Page="~/UploadItemPicture.aspx" %>

You can check out the full solution at:

http://odetocode.com/Blogs/scott/archive/2005/09/12/2186.aspx or
http://west-wind.com/weblog/posts/3016.aspx

Please note that there are other causes of this error message, such as conflicting object names in the same namespace.

This error occurs, if you have declared a class twice in your application (in a referenced assembly, somewhere in your app_code directory, or anywhere else in your app).
In my case I had a prior
compiled version (a dll) of the web app itself in the bin directory, which is
not allowed any more. -> delete all compiled versions of all web applications
(the app itself and referenced web apps) from the bin directory !!If you have to
have the same
classname multiple times within your application (e.g a class
"DataAccess"
within each module subfolder in the app_code directory, you
could do the
following:1) Give each class a different namespace (e.g.
MODULENAME.DataAccess)2) Mark the classes as partial classes (!! this does not
work if the partial classes are spread accross different subfolders of the
app_code dir which are marked as codeSubDirectory in the web.config. The reason
is, that in this case, each subfolder results in a different assembly and
partial classes over multiple assemblies are not allowed. Also see my blog
entry
for creating multiple assemblies from the app_code directory
!!)
Check out the full posting at http://www.cubido.net/Blog/tabid/176/EntryID/49/Default.aspx

If you have any tips you would like to share please email them to me at chrisw_88@hotmail.com








Be one of the first to try Windows Live Mail. Windows Live Mail.

Friday, May 19, 2006

Creating Custom Web Controls (Server Controls)

The following are links to examples on how to create a variety of custom web controls

If you have any more custom web control links to share please email them to me at
chrisw_88@hotmail.com

Wednesday, May 10, 2006

How To Change Master Pages Dynamically at runtime

Changing MasterPages dynamically is a simple task, but there is a catch. MasterPage can be changed in PreInit page or earlier. At this stage control tree is not constructed yet. The question is: "How can we use postback event to change MasterPage?" Usual solution for this problem is to save selected MasterPage file name into session, reload page and in PreInit set MasterPage according to persisted value. This works but requires additional roundtrip. Another solution is to intercept postback events in PreInit and process it, so here it is:


ASPX:
@ Page MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
<asp:DropDownList ID="MasterSwitch" runat="server" AutoPostBack="true">
<asp:ListItem Text="Simple Layout" Value="MasterPage.master">asp:ListItem>
<asp:ListItem Text="Complex Style" Value="MasterPageComplex.master">asp:ListItem>
<asp<:DropDownList>
<div<>>
<asp<>:Content>


Codebeside:
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;
public partial class Default : System.Web.UI.Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
switchMaster();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session[
"MasterSwitch"] = this.MasterSwitch.UniqueID;
}
}
private void switchMaster()
{
if (IsPostBack)
{
// Get control that fire postback event
string eventTarget = Request.Form["__EVENTTARGET"];
if (String.IsNullOrEmpty(eventTarget))
return;
// At this stage we don't have control tree yet,
// so we'll use previosly saved control ID
string switchControlName = (string)Session["MasterSwitch"];
if (String.IsNullOrEmpty(switchControlName))
return;
if (String.Compare(eventTarget, switchControlName, true) != 0)
return;
setMaster(Request.Form[eventTarget]);
}
}
private void setMaster(string masterName)
{
if (String.IsNullOrEmpty(masterName))
return;
// In real implementation some logic to convert
// selected value into real MasterPage File Name should be here
if (String.Compare(this.MasterPageFile, masterName, true) != 0)
this.MasterPageFile = masterName;
}
}




If you have any additional tips, tricks etc that you would like me to post to my blog, please email them to me at chrisw_88@hotmail.com




Wednesday, March 29, 2006

Multilingual characters in web.config

This is a good article on placing Multilingual characters in web.config

http://blogs.imason.com/chris.chapman/archive/2005/10/05/1833.aspx



If you have any additional tips, tricks etc that you would like me to post to my blog, please email them to me at chrisw_88@hotmail.com

Monday, March 20, 2006

Common Solution Links

This article will contain a list of other sites to find solutions to common problems.






If you have any suggestions for links to place here please email them to me at chrisw_88@hotmail.com

Wednesday, March 08, 2006

CTW ASP.NET Grid articles

Below is a good article on the gridview control:

http://www.gridviewgirl.com/GridViewGirl/articles.aspx



If you have any additional tips, tricks etc that you would like me to post to my blog, please email them to me at chrisw_88@hotmail.com

Monday, February 06, 2006

GridView Tips and Tricks

This article will contain a list of tips and tricks related to the using the GridView.










Formatting data using DataFormatString

EXAMPLE:


I was having an issue with it not applying my format. If it doesn’t work its one of the 3 key reasons below.For me I did not have HtmlEncode set to false.

The key properties are as follows:

o HtmlEncode = "False" ensures that the formatting is applied when displaying the date field. Without it, the formatting doesn't apply for some unknown reason.

o ApplyFormatInEditMode = "True" ensures that the DataFormatString is also applied when you change to the Edit mode. Without it, the formatting is ignored in Edit mode.

Introduction

Welcome to the ASP.NET 2.0 Tips and Tricks page.

This blog is designed to contain various Tips and Tricks to help you with your ASP.NET 2.0
development. Since there are a lot of changes from ASP.NET 1.1 to 2.0 hopefully this will
help you with some of the pot-holes found during transition from 1.1 to 2.0 as well.

If you know any Tips or Tricks I can add to this blog please email them to me at chrisw_88@hotmail.com

Are you a .NET Developer or Contractor interested in working with Sitecore or Dynamics CRM?

Apply for our Mentorship Program. If accepted, we will mentor you on Sitecore and provide you with project to help you build your skills and make some money at the same time. If you are interested send your resume with details on why you want to work with Sitecore or Dynamics CRM to: Chris Williams - chris.williams@techguilds.com or Dennis Augustine - dennis.augustine@techguilds.com We look forward to working with you to achieve your goals.