SOLVED: Could not load type ‘System.Web.UI.ScriptReferenceBase’

June 23rd, 2011 by admin No comments »
Getting problems when you upload your Ajax Control Toolkit powered website up to your server? Read on for a quick and easy solution!

Scenario

If you have added some of the Ajax Control Toolkit extenders into your website you will have probably tested them out on your local dev computer and marvelled at how easy it was to add some impressive eye candy to your site. Then, just when you think your work is done for the day and its time to put your new creation online you are hit with an error:
Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Well you don't need to worry too much because this time it is a really simple fix.

Quick Fix

If your site has just broken and you want to get it running quickly then the simplest solution is to change your <cc1:ToolkitScriptManager> tag to be just a plain <asp:ScriptManager> tag. The ToolkitScriptManager is a wrapper control which provides the features of ScriptManager but also has a script combining feature to reduce the number of external javascript references generated by the toolkit. So its as simple as taking your code
<cc1:ToolkitScriptManager runat="server" ... />
and changing it to
<asp:ScriptManager runat="server" ... />

(You might have a different prefix than cc1 but it doesn't matter).

The Real Fix

The real reason that your site is throwing the error is that the latest version of Ajax Control Toolkit expects to have a .net 3.5 SP1 runtime environment. The key bit here is the SP1 which means Service Pack 1. To fix it you simply need to install the SP1 release which can be downloaded from here: This needs to be run on your server so you will need remote desktop access to do this. This kind of control over your server is typically only available with dedicated servers or VPS virtual servers. If you have a simple shared hosting package then you need to contact your web host and find out why they haven't upgraded yet. The SP1 release was a major upgrade which not only has many bug fixes included in it but also some great new features such as ASP.NET Dynamic Data. You can read all about the new features on the download link above. In the worst case scenario where you cant get your host to upgrade and you cant move hosts because you are locked into a contract with them then you can at least fall back on the quick fix listed in the middle of this article to get your site running again.

Imagine Cup 2011

March 20th, 2011 by admin No comments »

Participate in the world’s largest premier student technology competition

Microsoft Imagine Cup is the world’s largest premier student technology competition. It encourages students around the globe to imagine a better world in which people are empowered by technology.

Last year, more than 2,500+ students from Pakistan participated in this competition and team Magno Touch from University of Engineering and Technology (UET), Lahore won the Pakistan finals and represented Pakistan in the global finals held in Warsaw, Poland.

This year, the Imagine Cup 2011 – Global Finals will be held in United States of America (USA) and the winning team in the Software Design Category from Pakistan will be fully sponsored by Microsoft to go to the United States of America and compete in the global finals.

SOFTWARE DESIGN PAKISTAN – SCHEDULE:

ROUND START DATE

(all times 00:01 [12:01 A.M.] GMT)

END DATE

(all times 23:59 [11:59 P.M.] GMT)

Round 1 -One page document describing the idea July 9, 2010 March 20, 2011
Round 2 – Detailed project document along with screen shots March 20, 2011 April 10, 2011
Round 3 – Project presentation for top 5 teams April 27, 2011 April 27, 2011
Round 4 – Worldwide Finals July 2011 July 2011
Email your entries for Round 1 at: b-hashau@microsoft.com before March 20, 2011

Visit: http://pakistan.imaginecup.com for further details.

How to access server side controls in javacript when using masterpages

September 19th, 2010 by Javaid No comments »

It is very obvious when we inherit some page from Master page than we come with an issues that we cannot access the server control with their names. for instance if you have declared a text box and set its ID to say txtName than you cant access this control with its ID in JavaScript when you have used master pages.The reason is simple as you have used master page so it renames every control with its pre name like ctl00 and your control ID will become from txtNAme to ctl00txtName.
To solve this problem you need to do the following in JavaScript when you want to access the control through JavaScript for some validation or other processing.
<%=txtName.ClientID%> will actually point to txtNname therfore you can have access to the control and get its value using that script.
you can do like this
document.getElementById(‘<%=txtName.ClientID%>‘) for master pages
and document.getElementById(‘txtName’); for simple aspx page page that do not inherit from master pages

How to use Jquery to Accomplish AJAX in ASP.NET

July 18th, 2010 by Javaid 2 comments »

How to use Jquery to Accomplish AJAX in ASP.NET

In this article I will go through jquery and will show you how you can use jquery ajax effectively.

First you need to create a page let’s say named it ajax.aspx than you need to create another page let’s say process.aspx and remember do not create separate code file for this page.
Now add reference of jquery in ajax.aspx file you can download it from jquery.com
Now put this code in ajax.aspx file
put this code script tag
$.get(‘process.aspx?action=tes’, Process);

Function Process(ret)
{
Alert(ret);
}

In this $.get function there are two parameters first where we want to go and fetch data and second is the function where we want the data to be processed so I named the function as process after we get data from process.aspx the variable ret contains the value of data that we get from process.aspx and we alert it here.

So here the sample code for process.aspx file
put this code in script tag with runat server in aspx file
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(DateTime.Now.ToString());
Response.End();
}

In the load function I am returning dattime so here you can implement any logic according to your requirements.
The response.End ends the document immediately after returning the date means it will only return the date value if you don’t write response.end the it will read all the document and return you the date as well as all the parsed document.

Conclusion
This is the nice and easiest way to use ajax. Do let me know if you need more assistance.

Automatically submitting form in C#,ASP.NET

July 6th, 2010 by Javaid 2 comments »

How to Post Form Programmatically in C#, ASP.NET

In this article I will take you through the steps for submitting form programmatically.Well for this you don’t have to be genius enough just I assume you have basic understandings of C# and webrequest and webresponse.

If you don’t have basic understanding of webresponse than you can read this article

http://blog.jmaks.com/?p=31

Here we go

First open the page where you want to submit the form.open its view source and locate the form tag.

Now get the names of every input field within the form tags I assume there are two fields username and Fullname.

Now write it as following

string PostData = username=ABC&Fullname=SOMENAME;

now you need to write url In form action here.

string Formurl=”someurl”

Now create request

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Formurl);

We need to keep connection alive so make it true

request.KeepAlive = true;

now our request is for posting set it to POST

request.Method = “POST”;

we don’t want the page to auto redirect so make it false

request.AllowAutoRedirect = false;

request.ServicePoint.Expect100Continue = false;

here we split the data in to bytes

byte[] postBytes = Encoding.ASCII.GetBytes(postData);

request.ContentType = “application/x-www-form-urlencoded”;

request.ContentLength = postBytes.Length;

here we actually writing data to steam fro posting

Stream requestStream = request.GetRequestStream();

requestStream.Write(postBytes, 0, postBytes.Length);

requestStream.Close();

Now we are making the request and storing the response in response object

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

After posting data we get the response in some string  and we read it

string bc = new StreamReader(response.GetResponseStream()).ReadToEnd();

That’s it we have successfully submitted the form any suggestions are welcome

Thanks

Understanding Webrequest and Webresponse in C#,ASP.NET

July 6th, 2010 by Javaid 1 comment »

Webrequest and Webresponse in C#

The .NET Framework uses a Uniform Resource Identifier (URI) to identify the requested Internet resource and communication protocol. The URI consists of atleast three, and possibly four, fragments: the scheme identifier, which identifies the communications protocol for the request and response; the server identifier, which consists of either a Domain Name System (DNS) host name or a TCP address that uniquely identifies the server on the Internet; the path identifier, which locates the requested information on the server; and an optional query string, which passes information from the client to the server. For example, the URI “http://www.MyWebSite.com/whatsnew.aspx?date=today” consists of the scheme identifier “http”, the server identifier “www. MyWebSite.com”, the path “/whatsnew.aspx”, and the query string “?date=today”.

After the server has received the request and processed the response, it returns the response to the client application. The response includes supplemental information, such as the type of the content (raw text or XML data, for example).

Developing applications that run in the distributed operating environment of today’s Internet requires an efficient, easy-to-use method for retrieving data from resources of all types. Pluggable protocols let you develop applications that use a single interface to retrieve data from multiple Internet protocols.

The .NET Framework uses specific classes to provide the three pieces of information required to access Internet resources through a request/response model: the Uri class, which contains the URI of the Internet resource you are seeking; the HttpWebRequest class, which contains a request for the resource; and the HttpWebResponse class, which provides a container for the incoming response.

What is ADO.Net?

July 3rd, 2010 by saqib 1 comment »

Most of the today’s applications need to interact with database systems to persist, edit or view data. In .NET data access service is provided through ADO.NET (ActiveX Data Object in DOTNET) components. ADO.NET is an object oriented framework that allows you to interact with database systems. We usually interact with database systems through SQL queries or stored procedures. ADO.NET encapsulates our queries and commands to provide a uniform access to various database management systems.

ADO.NET is a successor of ADO (ActiveX Data Object). The prime features of ADO.NET are its disconnected data access architecture and XML integration.

What’s the difference between accessing data with dataset or data reader?

The data set is generally used when you like to employ the disconnected architecture of the ADO.Net. It reads the data into the local memory buffer and perform the data operations (update, insert, delete) locally to this buffer.

The data reader, on the other hand, is directly connected to the database management system. It passes all the queries to the database management system, which executes them and returns the result back to the application. Since no memory buffer is maintained by the data reader, it takes up fewer resources and performs more efficiently with small number of data operations.

The dataset, on the other hand is more efficient when large number of updates are to be made to the database. All the updates are done in the local memory and are updated to the database in a batch. Since database connection remains open for the short time, the database management system does not get flooded with the incoming requests.

What does it mean by disconnected data access architecture of ADO.Net?

ADO.Net introduces the concept of disconnected data architecture. In traditional data access components, you make a connection to the database system and then interact with it through SQL queries using the connection. The application stays connected to the DB system even when it is not using DB services. This commonly wastes the valuable and expensive database resource as most of the time applications only query and view the persistent data. ADO.Net solves this problem by managing a local buffer of persistent data called data set. Your application automatically connects to the database server when it needs to pass some query and then disconnects immediately after getting the result back and storing it in dataset. This design of ADO.Net is called disconnected data architecture and is very much similar to the connection less services of http over the internet. It should be noted that ADO.Net also provides the connection oriented traditional data access services

To select dataset or data reader?

The data reader is more useful when you need to work with large number of tables, database in non-uniform pattern and you need not execute the large no. of queries on few particular table.
When you need to work on fewer no. of tables and most of the time you need to execute queries on these fewer tables, you should go for the dataset.
It also depends on the nature of application. If multiple users are using the database and the database needs to be updated every time, you must not use the dataset. For this, .Net provides the connection oriented architecture. But in the scenarios where instant update of database is not required, dataset provides optimal performance by making the changes locally and connecting to database later to update a whole batch of data. This also reduces the network bandwidth if the database is accessed through network.
Disconnected data access is suited most to read only services. On the down side, disconnected data access architecture is not designed to be used in the networked environment where multiple users are updating data simultaneously and each of them needs to be aware of current state of database at any time (e.g., Airline Reservation System).

How XML is supported in ADO.Net?

The dataset is represented in the memory as an XML document. You can fill the dataset by XML and can also get the result in the form of XML. Since XML is an international and widely accepted standard, you can read the data using the ADO.Net in the XML form and pass it to other applications using Web Service. These data consuming application need not be the essentially Dot Net based. They may be written with Java, C++ or any other programming language and running on any platform.

Some core classes of ADO.NET

1. What is a dataset?
A dataset is the local repository of the data used to store the tables and disconnected record set. When using disconnected architecture, all the updates are made locally to dataset and then the updates are performed to the database as a batch.

2. What is a data adapter?
A data adapter is the component that exists between the local repository (dataset) and the physical database. It contains the four different commands (SELECT, INSERT, UPDATE and DELETE). It uses these commands to fetch the data from the DB and fill into the dataset and to perform updates done in the dataset to the physical database. It is the data adapter that is responsible for opening and closing the database connection and communicates with the dataset.

3. What is a database connection?
A database connection represents a communication channel between you application and database management system (DBMS). The application uses this connection to pass the commands and queries to the database and obtain the results of the operations from the database.

4. What is a database command?
A database command specifies which particular action you want to perform to the database. The commands are in the form of SQL (Structured Query Language). There are four basic SQL statements that can be passed to the database.

The Dot Net Framework 1.1 is shipped with four different Data Providers:
1. Dot Net Framework data provider for Microsoft SQL Server DBMS
2. Dot Net Framework data provider for Oracle DBMS (available only in Framework 1.1)
3. Dot Net Framework data provider for OLEDB supporting DBMS
4. Dot Net Framework data provider for ODBC supporting data sources (available only in Framework 1.1)

Why should one use a specialized data provider when the data can be accessed with general data providers?
The specialized data providers (e.g., SQL Server and Oracle) are built specially for a particular kind of DBMS and works much more efficiently than the general data providers (e.g., OLEDB and ODBC). In practice, the specialized data providers are many times efficient than the general data providers.

1. What is the Dot Net Framework data provider for SQL Server?
The dot net framework data provider for SQL Server is the optimized data provider for Microsoft SQL Server 7 or later. It is recommended to use SQL Server data provider to access the SQL Server DB than general provider like OLEDB. The classes for this provider are present in the System.Data.SqlClient namespace.

2. What is the Dot Net Framework data provider for Oracle?
The dot net framework data provider for Oracle is the optimized data provider for Oracle DBMS. It is recommended to use Oracle data provider to access the Oracle DB than general provider like OLEDB. It supports the Oracle Client version 8.1.7 and later. The classes for this provider are present in the System.Data.OracleClient namespace. This provider is included in the .Net framework 1.1 and was not available in the Dot Net framework 1.0.

3. What is the Dot Net Framework data provider for OLEDB?
The dot net framework data provider for OLEDB provides connectivity with the OLEDB supported database management systems. It is the recommended middle tier for the SQL Server 6.5 or earlier and Microsoft Access Database. It is a general data provider. You can also use it to connect with the SQL Server or Oracle Database Management Systems. The classes for this provider are present in the System.Data.OleDBClient namespace.

4. What is the Dot Net Framework data provider for ODBC?
The dot net framework data provider for ODBC provides connectivity with the ODBC supported database management systems and data sources. It is a general data provider. You can also use it to connect with the SQL Server or Oracle Database Management Systems. The classes for this provider are present in the System.Data.ODBCClient namespace. This provider is included in the .Net framework 1.1 and was not available in the Dot Net framework 1.0.

How to send email using C#

July 1st, 2010 by Javaid 2 comments »

How to send email using C#

Sending email using C# is as hard as you can think of you can easily do it in these simple steps.

  • Create Message Object
  • Create Body of the Message
  • Add Senders/Receivers’ and subject
  • Specify your credential details and host info
  • Send the mail

Now how we actually code it here we go

Add Namespace

using System.Net.Mail;

Create Mail Object

MailMessage m = new MailMessage(“FROM”, “TO”);

NOW ENTER TEXT FOR BODY

m.Body = “SAMPLE BODY”;

Now if you are sending email in html format like you have added images font styles etc than you can turn IsBodyHtml to true otherwise false

m.IsBodyHtml = true;

Now create smtpclient Object and pass it host info and port

SmtpClient smtp = new SmtpClient(“HOST”,”PORT”);

Now add your credential information

smtp.Credentials = new System.Net.NetworkCredential(“USERNAME”, “PASSWORD”);

Now this step is important if your host require SSL than enable this to true otherwise false

smtp.EnableSsl = true;

Now finally send the email

smtp.Send(m);

In case of any issues please feel free to post here. I would be very happy to help you out.

Could not load file or assembly Microsoft.SqlServer.Management.Sdk.Sfc

July 1st, 2010 by Javaid 5 comments »

Another sick error of the day, When you try to create connection string from SQLDatasource or even want to bind existing connection string. You might see a Message box saying

Could not load file or assembly ‘Microsoft.SqlServer.Management.Sdk.Sfc, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91′ or one of its dependencies. The system cannot find the file specified.

This error comes when you are trying to access SQL 2005 stuff from Visual Studio 2008.  So go to the link and download the following stuff

  • Microsoft SQL Server System CLR Types
  • Microsoft SQL Server 2008 Management Objects
  • Microsoft SQL Server 2008 Native Client

SEO

July 1st, 2010 by Javaid 1 comment »

SEO

SEO stands for Search Engine Optimization; it is widely used for marketing purposes and to list down the site in top ranks. For instance when you type a keyword or some sort of query in search engine than it crawls the related sites that contain those keywords or query and represent you the closest result.

Search engine optimization is often about making small modifications to parts of your website. When viewed individually, these changes might seem like incremental improvements, but when combined with other optimizations, they could have a noticeable impact on your site’s user experience and performance in organic search results.

Create unique, accurate page titles

A title tag tells both users and search engines what the topic of a particular page is. The <title> tag should be placed within the <head> tag of the HTML document. Ideally, you should create a unique title for each page on your site.

If your document appears in a search results page, the contents of the title tag will usually appear in the first line of the results. Words in the title are bolded if they appear in the user’s search query. This can help users recognize if the page is likely to be relevant to their search. The title for your homepage can list the name of your website/business and could include other bits of important information like the physical location of the business or maybe a few of its main focuses or Offerings.

Good practices for page title tags

• Accurately describe the page’s content - Choose a title that effectively communicates the

Topic of the page’s content.

Avoid:

• choosing a title that has no relation to the content on the page

• using default or vague titles like “Untitled” or “New Page 1″

• Create unique title tags for each page – Each of your pages should ideally have a unique

Title tag, which helps Google know how the page is distinct from the others on your site.

Avoid:

• using a single title tag across all of your site’s pages or a large group of pages

• Use brief, but descriptive titles – Titles can be both short and informative. If the title is too

Long, Google will show only a portion of it in the search result.

Avoid:

• using extremely lengthy titles that are unhelpful to users

• stuffing unneeded keywords in your title tags

Make use of the “description” Meta tag

A page’s description Meta tag gives Google and other search engines a summary of what the page is about. Whereas a page’s title may be a few words or a phrase, a page’s description Meta tag might be a sentence or two or a short paragraph. Like the <title> tag, the description Meta tag is placed within the <head> tag of your HTML document.

Description Meta tags is important because Google might use them as snippets for your pages. Note that we say “might” because Google may choose to use a relevant section of your page’s visible text if it does a good job of matching up with a user’s query. Adding description Meta tags to each of your pages is always a good practice in case Google cannot find a good selection of text to use in the snippet.

Good practices for description Meta tags

• Accurately summarize the page’s content - Write a description that would both inform and

Interest users if they saw your description Meta tag as a snippet in a search result.

Avoid:

• writing a description Meta tag that has no relation to the content on the page

• Using generic descriptions like “This is a webpage” or “Page about baseball cards”

• filling the description with only keywords

• Copy and pasting the entire content of the document into the description Meta tag

• Use unique descriptions for each page – Having a different description Meta tag for each Page helps both users and Google, especially in searches where users may bring up multiple pages on your domain (e.g. searches using the site: operator). If your site has Thousands or even millions of pages, hand-crafting description Meta tags probably isn’t Feasible. In this case, you could automatically generate description Meta tags based on each page’s content.

Avoid:

• using a single description Meta tag across all of your site’s pages or a large Group of pages

Improve the structure of your URLs

Creating descriptive categories and filenames for the documents on your website can not only help you keep your site better organized, but it could also lead to better crawling of your documents by search engines. Also, it can create easier, “friendlier” URLs for those that want to link to your content. Visitors may be intimidated by extremely long and cryptic URLs that contain few recognizable words. A URL to a page on our baseball card site that a user might have a hard time with URLs like these can be confusing and unfriendly. Users would have a hard time reciting the URL from memory or creating a link to it. Also, users may believe that a portion of the URL is unnecessary, especially if the URL shows many unrecognizable parameters.

They might leave off a part, breaking the link. Some users might link to your page using the URL of that page as the anchor text. If your URL contains relevant words, this provides users and search engines with more information about the page than an ID or oddly named parameter would.

Good practices for URL structure

• Use words in URLs – URLs with words that are relevant to your site’s content and structure are friendlier for visitors navigating your site. Visitors remember them better and might be more willing to link to them.

Avoid:

• using lengthy URLs with unnecessary parameters and session IDs

• choosing generic page names like “page1.html”

• using excessive keywords like “baseball-cards-baseball-cards-baseballcards.htm”

• Create a simple directory structure - Use a directory structure that organizes your content well and is easy for visitors to know where they’re at on your site. Try using your directory structure to indicate the type of content found at that URL.

Avoid:

• having deep nesting of subdirectories like “…/dir1/dir2/dir3/dir4/dir5/dir6/page.html”

• using directory names that have no relation to the content in them

• Provide one version of a URL to reach a document – To prevent users from linking to one version of a URL and others linking to a different version (this could split the reputation of that content between the URLs), focus on using and referring to one URL in the structure and internal linking of your pages. If you do find that people are accessing the same content through multiple URLs, setting up a 301 redirect from non-preferred URLs to the dominant URL is a good solution for this.

Avoid:

• having pages from sub domains and the root directory (e.g. “domain.com/page.htm” and “sub.domain.com/page.htm”) access the same content

• mixing www. And non-www. Versions of URLs in your internal linking structure

• using odd capitalization of URLs (many users expect lower-case URLs and remember them better)

Make your site easier to navigate

The navigation of a website is important in helping visitors quickly find the content they want. It can also help search engines understand what content the webmaster thinks is important. Although Google’s search results are provided at a page level, Google also likes to have a sense of what role a page plays in the bigger picture of the site. All sites have a home or “root” page, which is usually the most frequented page on the site and the starting place of navigation for many visitors. Unless your site has only a handful of pages, you should think about how visitors will go from a general page (your root page) to a page containing more specific content.

Good practices for site navigation

• Create a naturally flowing hierarchy – Make it as easy as possible for users to go from general content to the more specific content they want on your site. Add navigation pages when it makes sense and effectively work these into your internal link structure.

Avoid:

• creating complex webs of navigation links, e.g. linking every page on your site to every other page

• going overboard with slicing and dicing your content (it takes twenty clicks to get to deep content)

• Use mostly text for navigation – Controlling most of the navigation from page to page on your site through text links makes it easier for search engines to crawl and understand your site. Many users also prefer this over other approaches, especially on some devices that might not handle Flash or JavaScript.

Avoid:

• having a navigation based entirely on drop-down menus, images, or animations (many, but not all, search engines can discover such links on a site, but if a user can reach all pages on a site via normal text links, this will improve the accessibility of your site.

Write better anchor text

Anchor text is the clickable text that users will see as a result of a link, and is placed within the anchor tag <a href=”…”></a>. This text tells users and Google something about the page you’re linking to. Links on your page may be internal—pointing to other pages on your site—or external—leading to content on other sites. In either of these cases, the better your anchor text is, the easier it is for users to navigate and for Google to understand what the page you’re linking to is about.

Use heading tags appropriately

Heading tags (not to be confused with the <head> HTML tag or HTTP headers) are used to present structure on the page to users. There are six sizes of heading tags, beginning with <h1>, the most important, and ending with <h6>, the least important.

Optimize your use of images

Images may seem like a straightforward component of your site, but you can optimize your use of them. All images can have a distinct filename and “alt” attribute, both of which you should take advantage of. The “alt” attribute allows you to specify alternative text for the image if it cannot be displayed for some reason.

Conclusion

These are the basic tips for a new starter hence you can improve your skills by doing more research on SEO by the passage of time. Any comments and suggestions are welcome.

References

Google Guide for SEO