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.

Tuesday, February 20, 2007

The 'name' does not exist in this context

Sometimes Visual Studio 2005 will hiccup and you will get the error:

"The 'name' does not exist in this context"

I fixed it by doing the following:

  • Exclude file from project

  • Build

  • Exit VS 2005

  • Open VS 2005

  • Add back to project and build again

This fixes it. The other alternative is to reference the control directly in the content placeholder.
You can check out the Microsoft Forums posting for it at:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PageIndex=2&SiteID=1&PostID=200532
If you have any tips, tricks, fixes that you think would help others please email them to me at chrisw_88@hotmail.com and I will post them here.

Thursday, February 08, 2007

Default button in ASP.NET 2.0

Its easier to make the enter key run a button for controls in a block.
Here is a link to a sample:

http://dotavery.com/blog/archive/2006/02/08/7783.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

Custom XML Schema Generator

I found this it and thought it may be useful in getting around the ASP.NET Dataset issue where it ignores namespaces in the xml files. But unfortunately it ignores namespaces too. But possibly it can be modified to support it. If someone manages to modify it to support such things please let me know and I can post it here.

http://www.123aspx.com/redir.aspx?res=29483

If you have found any other generators or know of a workaround to the Dataset namespace ignoring issue let me know.

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

ClientScriptManager.RegisterForEventValidation !!!

It seems in .NET 2.0 it is more picky on doing postbacks from controls. Here is an article that gives a sample on how to use ClientScriptManager.RegisterForEventValidation so you avoid this mess.

http://www.velocityreviews.com/forums/t115194-sample-usage-of-clientscriptmanagerregisterforeventvalidation.html


The other option is to add the following to the <@ page directive:

EnableEventValidation="false"

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

Tuesday, January 16, 2007

Flash and Firefox popup blocker issue

If you open a window on press its considered spyware but if you do it on release its ok.

Although not specifically ASP.NET 2.0 I figured this may help out some developers doing flash and .NET.

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, 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

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.