Asp Dot Net Notes for Web Masters RSS 2.0

# Tuesday, February 01, 2011
How To submit a Asp.Net Form using GET method with no VIEWSTATE name/value pair in QueryString
Tuesday, February 01, 2011 1:15:32 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
JQuery | Asp.Net Controls
# Monday, January 03, 2011
An annoying error that has a very simple solution. You can put your 'code blocks' into a different control collection to solve this problem.
Monday, January 03, 2011 12:13:47 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Asp.Net Errors
# Tuesday, December 28, 2010
Proper hardware for serious programming professionals: Enhanced ThinkPad W701 with discrete graphics
Tuesday, December 28, 2010 5:34:14 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Hardware
# Saturday, September 25, 2010

Will I get into trouble with Google for showing different content to different users based on their location in the world?

I want to add a widget to a new website I am building. This widget is makes up only a small part of the content on the page. The widget will show about 6 search results. I want German users to see search results from Germany, UK users to see results from UK and USA users to see results from the USA etc.

I was a bit worried that this idea could be 'Cloaking' which is a 'Black Hat' promotion technique.

Thankfully it is not Black Hat at all and Google has no problem with showing different content to different users based on their location in the world? You jus must make sure that you treat GoogleBot the same as any other user. I.e. Do not make an extra effort to show GoogleBot content. Just let it be and let it see.

I was not planning on adding extra code to show GoogleBot in the USA different content than HumanUser in the USA, the same goes for all other locations, so I am not 'Cloaking'.

Below is a video from the official YouTube channel for Google Webmaster Central which explains that this technique is fine.



The next video has more information about IP Delivery: Background and Considerations

My plan was to show differently located users different content in the search widget on the page. But this means that a USA user who sends a link to his UK friend will see different content in the search widget. Really they should both be able to see the same content for the whole page including the search widget.

The following video tells us that a better solution would be to show the same content to both users and just to add a link to the local version for the foreign visitor. So I must choose a base local. E.g. USA and show users from the UK a link that allows them to see the UK version of the search widget.

Saturday, September 25, 2010 12:15:16 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
GeoTargeting | White Hat - Be Safe
# Thursday, August 19, 2010

LinqToSql SubmitChanges() not working

Have you ever tried to update a row in a database table using Ling ToSql and found that it does not work?

I had that situation and could not work out what was wrong. I was using simple code like the extract below:

          using (databaseDataContext db = new databaseDataContext())

            {

                //Update a record and display info

                localization item = (from o in db.localizations

                                     where o.Pk == 16606

                                     select o).First();

 

                item.ResourceSet = “newtext”;

 

                db.SubmitChanges();

 

            }

 

After messing about with the code I checked the ‘SQL Server Profiler tool’ and that showed me that there was no UPDATE statement being sent to the SQL server.

Why no UPDATE statement? Because my database table called ‘localizations’ has no Primary Key defined. The table did have a column called ‘Pk’ but it was not defined as a primary key in the Database Table. If there is no Primary Key defined then LinqToSql treats the table as read only.

To fix this I opened SQL Server Management Studio and designated the column ‘Pk’ as the primary key for the ‘localization’ table. I also had to do the same in my LinqToSql dbml file.  After specifying a primary key the SubmitChanges() command worked and the UPDATE statement was sent to the SQL server.

Note: The localization table I was using came from the Updated Westwind.Globalization Data Driven Resource Provider for ASP.NET  which is a very good project for enabling and managing multiple languages in your website or application. Most people would not need to run LinqToSql commands on the table but I need to correct a mistake in the naming of my resource sets.

Note: do not use the dash character ‘-‘ in the name of resource sets. Dot Net does not like the name of a resx file to have a ‘-‘  in it.

 

 

Thursday, August 19, 2010 1:24:55 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2] - Trackback
Westwind Globalization
# Tuesday, February 02, 2010
Accessing the columns of a Detail Table that belongs to a RadGrid can be difficult.

I wanted to make some columns ReadOnly because they are Data Key Names or Foreign Key Names. There may be another way to achieve this behaviour but I could not find it.

Below is the solution I came up with.

/// <summary>
/// Makes the ID rows readonly. Have to use because the cols are Generated automatically
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
protected void Websites_RadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    //##DetailTableDataBind Info at:
    //http://www.telerik.com/help/aspnet-ajax/grdhierarchicaldatabindingusingdetailtabledatabind.html         

    //Get the required cols 
    var Col1 = e.DetailTableView.AutoGeneratedColumns.SingleOrDefault(ColName => ColName.IsBoundToFieldName("DomainID"));
    var Col2 = e.DetailTableView.AutoGeneratedColumns.SingleOrDefault(ColName => ColName.IsBoundToFieldName("WebSiteID"));
    //If the col exists them make it read only.
    if (Col1 != null)
    {
        (Col1 as Telerik.Web.UI.GridBoundColumn).ReadOnly = true;
    }
    if (Col2 != null)
    {
        (Col2 as Telerik.Web.UI.GridBoundColumn).ReadOnly = true;
    }
}

Tuesday, February 02, 2010 12:07:10 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Controls
# Monday, December 07, 2009

My Setup

Operating System: Vista
Web Server: Microsoft IIS7 - Internet Information Services. This is the standard web server in the windows family.
Internet Connection: Connected to internet through a router.

Static IP address

Configure your PC so that when it connects to your router it will have a static IP address. Without a static IP address you may have to re-configure every time.

Here is a guide to setup Static IP address on Vista: http://portforward.com/networking/static-vista.htm

Virtual PC and XP Images

Download and install Microsoft Virtual PC 2007.  At the time of writing the Microsoft Virtual PC download and information pages are at:  http://www.microsoft.com/windows/virtual-pc/

Download and install a Virtual PC Image.  E.g. IE6-XPSP3.exe contains a Windows XP SP3 with IE6 VHD file. At the time of writing the Internet Explorer Application Compatibility VPC Image download page is at:  http://www.microsoft.com/downloads/details.aspx?FamilyID=21eabb90-958f-4b64-b5f1-73d0a413c8ef&displaylang=en

There are Virtual PC Images for testing IE6,IE7,IE8

Virtual PC Networking

When you have installed your Virtual PC 2007 and your selected Virtual PC, you will need to setup networking. In the Virtual PC Console select the Virtual PC you want to run and click settings. Select Networking in the list on the left. You should see a list of connection options. Select the one that is the Networking Controller that your Host PC is using to connect to the router. E.G. in my case it is “NVIDIA nForce Networking Controller”. The other options I have are “Not Connected”, “Local only”, “Shared Networking (NAT)”. You do not want to select any of those.

At this point you should be able to browse the internet in the Virtual PC using Internet Explorer. You can test live websites from here.

Virtual PC hosts file

To see websites on you host PC'c webserver, you must set the host PC's IP address in the Virtual PC's hosts file for each website you want to test.  The hosts file may be in this location: C:\WINDOWS\system32\drivers\etc

If not then you can use the windows search function to find it. Make sure that you tell it to search hidden folders.

Once you have found the hosts file you should make a shortcut to it and save it on the desktop of your Virtual PC. Then you can just add lines to the hosts file by opening it in Notepad.

E.g. My PC's static IP address is 192.168.1.8 so the line to add to the hosts file to see the website called localhost is:

192.168.1.8    localhost

Hopefully, now when you browse localhost on the Virtual PC you will now see the localhost website on the Host PC. You can setup all you development websites in the VPC hosts file so that you can test all your websites.



Monday, December 07, 2009 5:08:42 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Virtual PC
# Saturday, November 28, 2009
In Sitefinity, when editing a page if you click properties you can enter extra page URLs.

Add a new URL something like "~/home.html" and click Save Changes.

Then Make all html pages run as though Asp.Net pages. Look here.

http://dotnetnotes.i-do-it.com/2009/11/28/MapHTMLPagesThrougthASPNETDllRunHtmlPagesWithAspnetisapidll.aspx


Then add this to the Global.Asax
 void Application_Error(object sender, EventArgs e) 
    {        
//Redirect missing Old html Pages to the default url of that page. Add Additional Urls to pages in sitefinity to redirect to those pages.
        Exception lastException = this.Server.GetLastError();
        if (lastException is HttpException)
        {
            HttpException httpException = (HttpException)lastException;
            if (httpException.GetHttpCode() == 404)
            {
                // get the name of the requested page - just the /thisPage.htm or /DIR/thisPage.asp etc
                string pageName = string.Concat("~", Request.Url.AbsolutePath.ToString());

                // create a new instance of CmsManager
                Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();

                // let's get the page by passing one of it's additional url's
                Telerik.Cms.IPage myPage = cmsManager.GetPageByAdditionalUrl(pageName);

                // we can cast myPage as ICmsPage and redirect to the Default URL
                if (myPage != null)
                {
                    //If there isa default page then redirect to it.                    
                    this.Server.ClearError();                    
                    Response.Redirect(((Telerik.Cms.ICmsPage)myPage).DefaultUrl.Url);
                }
            }
        }
    }

Saturday, November 28, 2009 12:01:48 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Configuration
Here is the code needed to run HTML pages with asp.net. Add it to the Web.Config.

The code comes from this post:
http://forums.iis.net/p/1158398/1907100.aspx


<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <add name="ASPX-HTML-Integrated" path="*.html" verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" preCondition="integratedMode" /> <add name="ASPX-HTML-2.0-Classic-32bit" path="*.html" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" responseBufferLimit="0" /> </handlers> </system.webServer> <system.web> <compilation> <buildProviders> <add extension=".html" type="System.Web.Compilation.PageBuildProvider" /> </buildProviders> </compilation> <httpHandlers> <add path="*.html" type="System.Web.UI.PageHandlerFactory" verb="*" /> </httpHandlers> </system.web> </configuration>

Saturday, November 28, 2009 11:18:26 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Asp.Net Configuration
# Friday, August 14, 2009
Here is a list of good Affiliate Marketing Web Sites who are trust worthy:

MyHelpHub.com

One of the easiest affiliate networks to join and start using. They have a smaller number of products when compared to the larger networks but this makes it easier for you to get to grips with affiliate marketing and to understand the full range of products on offer. All the products are kind of related because they are all self help books/guides. This means that your web site visitors may very well be interested in more than one product form this network. Examples of the products on offer are: Self help guides like “how to beat parking tickets” and how to beat parking Tickets, speed cameras, Wheel clamp fines and more.
  • They have a 50% commission structure so if a product costs £15 you receive £7.50. That is not bad at all.
  • You can get your commissions as soon as they have been approved rather than waiting for your balance to reach a minimum payout level. They also have new trackable links so you can see how many clicks a link received.
  • Payments via Paypal.

Affiliate Window

A Newer Marketing company which is part of Digital Window Ltd. They have won numerous awards for their platform which continues to develop and gain more and more merchants. Seems like many merchants have moved from Trade Doubler to Affiliate Window.

Note:
Charges £5 to sign up but you will receive the £5 back with your first commission.


Features:
  • Customizable Data Feeds (Create-a-Feed tool)
  • Discount Codes
  • Banners and Links
  • Deep Link Builder
  • Easy Set up Online Product Comparison Website (Shop Window)
  • Content Widgets
  • Affiliate Service API - Get Account and Merchant Data via API
  • Product Serve API - Get Product Data via API

buy.at

A leader in its class with many great merchants.

Commission Junction

Good Affiliate Company. One negative point is that they will close your accunt if you do not make enough sales.

Trade Doubler

Great Affiliate Companywith many useful tools and over ten years in the business.

Google AdSense

The Affiliate program to use if you want to display adverts targeted to your website visitors. These are pay per click adverts in both text and image format. This is the easiest and quickest method of affiliate marketing because you do not need to create content. You just add some JavaScript to your page and adverts related to your existing content will be displayed. You can even block out adverts from your competitors if necessary.

Rackspace Cloud

A Great Host for Asp.Net Windows Websites and Linux based Websites. Has an affiliate program.

Cloud Computing & Cloud Hosting by Rackspace
Friday, August 14, 2009 5:25:32 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
Affiliate Marketing
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
I do I.T. Ltd.
Sign In
Statistics
Total Posts: 27
This Year: 0
This Month: 0
This Week: 0
Comments: 22
All Content © 2012, I do I.T. Ltd.