Getting problems when you upload your Ajax Control Toolkit powered website up to your server? Read on for a quick and easy solution!
ScenarioIf 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=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.Well you don't need to worry too much because this time it is a really simple fix.
The Real FixThe 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:
Ã¯Â»Â¿Ã¯Â»Â¿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:
(all times 00:01 [12:01 A.M.] GMT)
(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: firstname.lastname@example.org before March 20, 2011|
Visit: http://pakistan.imaginecup.com for further details.
<%=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
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
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)
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.
This is the nice and easiest way to use ajax. Do let me know if you need more assistance.
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
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.
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);
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
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.
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#
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
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
In case of any issues please feel free to post here. I would be very happy to help you out.
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 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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.
Ã¢â‚¬Â¢ 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)
Ã¢â‚¬Â¢ 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.
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.
Google Guide for SEO