AspNetSource.com's Official BlogAspNetSource's Official Blog

Articles for ASP.NET, AJAX, SQL, C#, VB.NET, etc.


Top Articles

<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Categories

AJAX  ASP.NET  C#  CSS  Design  General  SEO  SQL  VB.NET 

Links

Link to Us

(just copy-paste the text below in your page)

Author(s)

 
Posted by Tihomir Ivanov on 03 December 2008 07:45
Posted in: ASP.NET General 

Let's begin with an example of simple asp.net code:

<asp:ImageButton ID="_imgBtn" runat="server" ImageUrl="~/images/Img.jpg" Height="50px" 
Width="50px" BorderWidth="0px" BorderStyle="None" />


That's a valid asp.net code and it works fine, BUT when you try to validate it 
through W3C (http://validator.w3.org/) you will see error like this:

Error Line X column X : there is no attribute "border".

This is a problem caused by W3C running validation whilst reading the HTML rendered for a simple browser like Netscape !

Do you want your pages to be valid for old-fashioned browsers which nobody uses anymore?

If the answer of last question is 'No' here's a solution:

Add a BrowserFile.browser file with the content below inside an App_Browsers folder in the app's root. The section for validation tells it

to use the same code as IE 7 or Firefox will. Add this and your page should validate:

<!--
You can find existing browser definitions at
<windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
-->
<browsers>
<browser id="NewBrowser" parentID="Mozilla">
<identification>
<userAgent match="Unique User Agent Regular Expression" />
</identification>

<capture>
<userAgent match="NewBrowser (?'version'\d+\.\d+)" />
</capture>

<capabilities>
<capability name="browser" value="My New Browser" />
<capability name="version" value="${version}" />
</capabilities>
</browser>

<browser refID="Mozilla">
<capabilities>
<capability name="xml" value="true" />
</capabilities>
</browser>
<browser id="w3cValidator" parentID="default">
<identification>
<userAgent match="^W3C_Validator" />
</identification>

<capture>
<userAgent match="^W3C_Validator/(?'version'(?'major'\d+)(?'minor'\.\d+)\w*).*" />
</capture>

<capabilities>
<capability name="browser" value="w3cValidator" />
<capability name="majorversion" value="${major}" />
<capability name="minorversion" value="${minor}" />
<capability name="version" value="${version}" />
<capability name="w3cdomversion" value="1.0" />
<capability name="xml" value="true" />
<capability name="tagWriter" value="System.Web.UI.HtmlTextWriter" />
</capabilities>
</browser>
</browsers>

 

That's All :) Happy Coding :)

Posted by Tihomir Ivanov on 19 November 2008 17:03
Posted in: General 

We've received some mails form our visitors, they asked us why we need to collect their names and e-mails when they download our free products. We've really don't need users names and e-mails. That's why we removed all fields for downloading our free products:

 

To download a product, just click on the 'Download NOW' button.

That's all. We hope to make your visits here more and more comfortable :)

Posted by Tihomir Ivanov on 13 November 2008 09:40
Posted in: ASP.NET 

Sometimes it's usefull when your someone clicks in your textbox, whole text inside it to become selected. We use it in 'Link to Us' textbox. Follows example how you can do it:

in aspx page:

<asp:TextBox ID="_linkToUsTB" runat="server" TextMode="MultiLine" Width="150px" Height="100px"></asp:TextBox>

 

in code-behind:

protected void Page_Load(object sender, EventArgs e)
{

. . .

_linkToUsTB.Text = "<a href=\"http://www.aspnetsource.com\" title=\"asp.net directory\">" +

+ "<img style=\"border-width: 0px; height: 70px; width: 116px;\"src=\"http://www.aspnetsource.com/images/logo.jpg\" alt=\"asp.net directory\" />"

+ "</a>";


_linkToUsTB.Attributes.Add("onClick", "javascript:this.form." + _linkToUsTB.ClientID + ".focus(); this.form." + _linkToUsTB.ClientID + ".select();");

. . .

}

The example works on IE (6, 7), FireFox, Opera, Safari and Chrome.

That's all. I hope it'll be usefull to someone too :)

Posted by Tihomir Ivanov on 07 November 2008 06:47
Posted in: SQL 

The DataContext class is the core channel that you use to work with (for example,
to query or update) your database. For each LTS DBML file you add to your solution, a new
DataContext will be created.
The DataContext class is a generated partial class that exists in your AdventureWorks.
designer.cs file. In this example, your partial class is called AdventureWorksDataContext, which
is based on the name that you gave the DBML file. As you can see in the example below, the DataContext
class contains the properties and methods for interacting with the table(s) that have been added
to the designer.
In addition to the properties and methods in the AdventureWorksDataContext class, you
can also see in the example below that the System.Data.Linq.DataContext is used as the base class. This
base class is part of the LINQ framework and contains the contract and implementation logic
to work with the database and the entities in the database. Some examples of what is in the
DataContext class include Refresh, CreateDatabase, GetTable, and SubmitChanges.

using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;

[System.Data.Linq.Mapping.DatabaseAttribute(Name="AdventureWorks")]
public partial class AdventureWorksDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource
mappingSource = new AttributeMappingSource ();
#region Extensibility Method Definitions
partial void OnCreated();
partial void InsertDepartment(Department instance);
partial void UpdateDepartment(Department instance);
partial void DeleteDepartment(Department instance);
#endregion
static AdventureWorksDataContext()
{
}
public AdventureWorksDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public AdventureWorksDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}

public AdventureWorksDataContext(string connection,
System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public AdventureWorksDataContext(System.Data.IDbConnection connection,
System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public AdventureWorksDataContext() :
base(global::
LTS_Harness.Properties.Settings.Default.
AdventureWorksConnectionString, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table<Department> Departments
{
get
{
return this.GetTable<Department>();
}
}
}

12345678910...


 
AspNetSource.com


 
Our Sponsors:  Asp.net file upload component