Multiple onload event in dot net

Definition

Once a page has been loaded 'onload' event executes a JavaScript immediately.

We can use onload function in number of ways:

1. <body onload="load1()">
2. <element onload="SomeJavaScriptCode">
3. object.onload="SomeJavaScriptCode"
4. window.onload = load;

function load1() {
  alert("This is the first.");
}

onLoad Event handlers Examples

<frameset onload="framload()">
<img src="logo.gif" onload="imgload()">

 

USE of onload

 

This is used to invoke JavaScript function after the page or an image has finished loading.

 

How to get requesting page in C#

We can get requesting page url in C# to use below statement
Request.UrlReferrer.OriginalString

We can also check the particular page
if (Request.UrlReferrer.OriginalString.IndexOf("confirmation.aspx") > -1)
            {
// Code Here
                      }
We should include the namespace before that.
using System.Web;

Find iphone browser in c# code

I need to find the site has been opened in mobile browser version or not, if it opened in iphone browser, then i need to redirect other page. So i use UserAgent to find operating system details.

if (Request.UserAgent.ToLower().Contains("iphone") == true)
        {
            //Response.Redirect("mobile.aspx");
        }

to get table names which are referenced by given table

Use this function to get table name which are referenced as foreign key by  given table's primary key

I want to find out that table names in database, a primary key of a table that referenced foreign key of another tables.

Here i have to pass the main table name and find out the tables the primary key of main table referenced the foreign key of another tables.


CREATE FUNCTION [dbo].[getForignkeyTblName1](@tblname varchar(50))
RETURNS @tbl TABLE(tblnames varchar(50))
AS
BEGIN
declare @objid int,@objname nvarchar(776),@result varchar(50)
INSERT INTO @tbl SELECT b.Name FROM sys.foreign_keys a
INNER JOIN sys.tables b
ON a.parent_object_id =b.object_id
 WHERE a.referenced_object_id =(SELECT object_id FROM  sys.tables WHERE name=@tblname)
return
END

--SELECT * FROM [getForignkeyTblName1]('MainTable')

What is Normalization?

Normalization is the process of designing a data model to efficiently store data in a database
  • Database normalization is a data design and organization process applied to data structures based on rules that help building relational databases.
  • In relational database design, the process of organizing data to minimize redundancy is called normalization.
  • Normalization usually involves dividing a database into two or more tables and defining relationships between the tables.
  • The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.

What are the Different Normalization Forms?

1NF - Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.

2NF -If an attribute depends on only part of a multi-valued key, then remove it to a separate table.

3NF -If attributes do not contribute to a description of the key, then remove them to a separate table. All attributes must be directly dependent on the primary key.

Rules for 3NF
  • To separate table for each set of related attributes, and give a primary key for each table.
  • If an attribute depends on only part of a multi-valued key, remove it to a separate table
  • If attributes do not contribute to a description of the key, remove them to a separate table.

Define Web Confiq

Web Config

     Web.config is the main settings and configuration file for an ASP.NET web application.
     The file is an XML document that defines configuration information regarding the web application.
     This file stores the information about how the web application will act.
     The web.config file contains information that control module loading, security configuration, session state configuration, application language compilation settings and connection String.

Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified

There are few things have to notice for above error, and do and check one by one.

1. Check that you are using correct version of ASP.Net in IIS( Check applicationpool ),if not select exact one. 
2. If your ASP.NET  Version is 3.5, Ajax dll inbuilted in Framework 3.5. So change your extension version to 3.5 in web confiq.
3. If your asp.net version is 2.0 you have to install ASPNET.2.0.AJAX.Extensions on your server.

Here i have given the link to download ASPNET.2.0.AJAX.Extensions.

4. Redirect old version to new version like below.
 
<runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
   <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
   <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
  </dependentAssembly>
  <dependentAssembly>
   <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
   <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
  </dependentAssembly>
 </assemblyBinding>
</runtime>

5. Change public key version to 31BF3856AD364E35(its work, how ? me too)

I hope this will help you.