Tuesday, 31 July 2012

"< noscript >...< /noscript >" in JAVASCRIPT


It also known as  "Javascript Fallback Content " 

People can turn Javascript off in their browser software which can cause your document to appear broken or incomplete to them if you are using Javascript to render content in any way. There are also situations in which automated software is attempting to index your document's content and it may not be able to process Javascript.
HTML sports a Javascript content fallback feature in which anyone without Javascript enabled will be served up your alternate content, while regular users see the Javascript enabled content. This is done using the <noscript> element of HTML.

If the user has Javascript enabled the <script> element will process while the <noscript> element is completely ignored. If the user does not have Javascript enabled the <script> element gets ignored, and the <noscript> element will process.



Example :

<head runat="server"><title></title><script type="text/javascript">
var myexp = "First Example";</script><script src="Demo.js"></script><noscript>This is no script content</noscript>head>body><form id="form1" runat="server"><div><script type="text/javascript">document.write(myexp);</script><br /><br /><script type="text/javascript">document.write(myExp);</script><noscript>This is no script content</noscript>
</
<

Wednesday, 25 July 2012

Cross Page Postback


Crosspage.aspx :

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net cross page postback example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Red">asp.net Cross-Page PostBack example</h2>
        <asp:Label
            ID="Label1"
            runat="server"
            Text="ProductID"
            ForeColor="DodgerBlue"
            >
        </asp:Label>
        <asp:TextBox
            ID="TextBox1"
            runat="server"
            ForeColor="AliceBlue"
            BackColor="DodgerBlue"
            >
        </asp:TextBox>
        <br />       
        <asp:Label
            ID="Label2"
            runat="server"
            Text="Product Name"
            ForeColor="DodgerBlue"
            >
        </asp:Label>
        <asp:TextBox
            ID="TextBox2"
            runat="server"
            ForeColor="AliceBlue"
            BackColor="DodgerBlue"
            >
        </asp:TextBox>
        <br />
        <asp:Button
            ID="Button1"
            runat="server"
            Text="Submit data"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            PostBackUrl="~/NextPage.aspx"
            />
    </div>
    </form>
</body>
</html>


NextPage.aspx - >

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e) {
        TextBox pvProductID = (TextBox)PreviousPage.FindControl("TextBox1");
        TextBox pvProductName = (TextBox)PreviousPage.FindControl("TextBox2");
        Label1.Text ="You came from: "+ PreviousPage.Title.ToString();
        Label2.Text = "Product ID: " + pvProductID.Text.ToString();
        Label2.Text += "<br />Product Name: " + pvProductName.Text.ToString();
        string imageSource = "~/Images/" + pvProductID.Text + ".jpg";
        Image1.ImageUrl = imageSource;
        Image1.BorderWidth = 2;
        Image1.BorderColor = System.Drawing.Color.DodgerBlue;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net Cross-Page PostBack example: how to submit a page to another page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Teal">asp.net cross page postback example</h2>
        <asp:Label ID="Label1" runat="server" ForeColor="Crimson">
        </asp:Label>
        <br />
        <asp:Label ID="Label2" runat="server" ForeColor="SeaGreen">
        </asp:Label>
        <br />
        <asp:Image ID="Image1" runat="server" />
    </div>
    </form>
</body>
</html>

Your result will be your description.

Tuesday, 24 July 2012

nav element in HTML5

Like <header>, <nav> is a section element with a clear purpose.
I have it on the left on this site though it's often placed horizontally above or below the header. Technically you can place it (or them – there can be more than one) anywhere you want, but remember never make it difficult for visitors. One of the most common mistakes beginners – and for that matter, many professionals – make is to not make navigation simple, straight forward and intuitive.
The <nav> element is for "major navigation blocks"*. It can go in the header or article tags (which we will look at next); or it can be on its own. On the left I have it on its own and in the article element the "previous" and "next" links are in nav tags.


Example  :


<!DOCTYPE html>
<html>
<body>
<nav>
<a href="/html/">HTML</a> |
<a href="/html5/">HTML5</a> |
<a href="/css/">CSS</a> |
<a href="/css3/">CSS3</a> |
<a href="/js/">JavaScript</a>
</nav>
</body>
</html>

The <nav> tag defines a section of navigation links.
Not all links of a document must be in a <nav> element. The <nav> element is intended only for major block of navigation links.
Browsers, such as screen readers for disabled users, can use this element to determine whether to omit the initial rendering of this content.

HOW TO USE THEAD , TBODY , TFOOT IN HTML


DESCCRIPTION :
The <tbody> tag is used to group the body content in an HTML table.
The <tbody> element is used in conjunction with the <thead> and <tfoot> elements to specify each part of a table (body, header, footer).
Browsers can use these elements to enable scrolling of the table body independently of the header and footer. Also, when printing a large table that spans multiple pages, these elements can enable the table header and footer to be printed at the top and bottom of each page.
The <tbody> tag must be used in the following context: As a child of a <table> element, after any <caption>, <colgroup>, and <thead> elements.
EXAMPLE :
<table border="1">
  <thead>
    <tr>
      <th>NIHAR </th>
      <th>BLOG</th>
    </tr>
  </thead>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>RS.180</td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td>January</td>
      <td>RS.100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>RS.80</td>
    </tr>
  </tbody>
</table>

Sunday, 22 July 2012

Difference between == and === in JAVASCRIPT / PHP

=== and !== are strict comparison operators:
JavaScript has both strict and type-converting equality comparison. For strict equality the objects being compared must have the same type and:
  • Two strings are strictly equal when they have the same sequence of characters, same length, and same characters in corresponding positions.
  • Two numbers are strictly equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal to one another.
  • Two Boolean operands are strictly equal if both are true or both are false.
  • Two objects are strictly equal if they refer to the same Object.
  • Null and Undefined types are == (but not ===).


Example :

               0==false   // true 



               1==="1"    // false, because they are of a different type 
               1=="1"     // true, auto type coercion 
               0===false  // false, because they are of a different type 

It also known as  "Javascript Fallback Content " 

People can turn Javascript off in their browser software which can cause your document to appear broken or incomplete to them if you are using Javascript to render content in any way. There are also situations in which automated software is attempting to index your document's content and it may not be able to process Javascript.
HTML sports a Javascript content fallback feature in which anyone without Javascript enabled will be served up your alternate content, while regular users see the Javascript enabled content. This is done using the <noscript> element of HTML.

If the user has Javascript enabled the <script> element will process while the <noscript> element is completely ignored. If the user does not have Javascript enabled the <script> element gets ignored, and the <noscript> element will process.



Example :

<head runat="server"><title></title><script type="text/javascript">
var myexp = "First Example";</script><script src="Demo.js"></script><noscript>This is no script content</noscript>head>body><form id="form1" runat="server"><div><script type="text/javascript">document.write(myexp);
</script><br /><br /><script type="text/javascript">document.write(myExp);
</script><noscript>This is no script content
</noscript>
</
<

Monday, 16 July 2012

ORA-01843: not a valid month

ORA-01843 not a valid month
 
Cause: A date specified an invalid month. Valid months are: January-December, for format code MONTH, and Jan-Dec, for format code MON.
 
Action: Enter a valid month value in the correct format


Example : 

How :-> 
  * FROM emp
SELECT
 WHERE

Error : ORA-01843: not a valid month


Solution :

SELECT * FROM emp
 WHERE


Try it !!

 

BIRTH_DT >= '31/DEC/1988' AND BIRTH_DT <= '31/DEC/2012'
BIRTH_DT >= '31/12/1988' AND BIRTH_DT <= '31/12/2012'

RESERVED KEYWORDS IN SQL / PL-SQL

PL/SQL Reserved Words have special meaning in PL/SQL, and may not be used
for identifier names (unless enclosed in "quotes").

An asterisk (*) indicates words are also SQL Reserved Words.

ALL*            DESC*           JAVA            PACKAGE         SUBTYPE
ALTER*          DISTINCT*       LEVEL*          PARTITION       SUCCESSFUL*
AND*            DO              LIKE*           PCTFREE*        SUM
ANY*            DROP*           LIMITED         PLS_INTEGER     SYNONYM*
ARRAY           ELSE*           LOCK*           POSITIVE        SYSDATE*
AS*             ELSIF           LONG*           POSITIVEN       TABLE*
ASC*            END             LOOP            PRAGMA          THEN*
AT              EXCEPTION       MAX             PRIOR*          TIME
AUTHID          EXCLUSIVE*      MIN             PRIVATE         TIMESTAMP
AVG             EXECUTE         MINUS*          PROCEDURE       TIMEZONE_ABBR
BEGIN           EXISTS*         MINUTE          PUBLIC*         TIMEZONE_HOUR
BETWEEN*        EXIT            MLSLABEL*       RAISE           TIMEZONE_MINUTE
BINARY_INTEGER  EXTENDS         MOD             RANGE           TIMEZONE_REGION
BODY            EXTRACT         MODE*           RAW*            TO*
BOOLEAN         FALSE           MONTH           REAL            TRIGGER*
BULK            FETCH           NATURAL         RECORD          TRUE
BY*             FLOAT*          NATURALN        REF             TYPE
CHAR*           FOR*            NEW             RELEASE         UI
CHAR_BASE       FORALL          NEXTVAL         RETURN          UNION*
CHECK*          FROM*           NOCOPY          REVERSE         UNIQUE*
CLOSE           FUNCTION        NOT*            ROLLBACK        UPDATE*
CLUSTER*        GOTO            NOWAIT*         ROW*            USE
COALESCE        GROUP*          NULL*           ROWID*          USER*
COLLECT         HAVING*         NULLIF          ROWNUM*         VALIDATE*
COMMENT*        HEAP            NUMBER*         ROWTYPE         VALUES*
COMMIT          HOUR            NUMBER_BASE     SAVEPOINT       VARCHAR*
COMPRESS*       IF              OCIROWID        SECOND          VARCHAR2*
CONNECT*        IMMEDIATE*      OF*             SELECT*         VARIANCE
CONSTANT        IN*             ON*             SEPERATE        VIEW*
CREATE*         INDEX*          OPAQUE          SET*            WHEN
CURRENT*        INDICATOR       OPEN            SHARE*          WHENEVER*
CURRVAL         INSERT*         OPERATOR        SMALLINT*       WHERE*
CURSOR          INTEGER*        OPTION*         SPACE           WHILE
DATE*           INTERFACE       OR*             SQL             WITH*
DAY             INTERSECT*      ORDER*          SQLCODE         WORK
DECIMAL*        INTERVAL        ORGANIZATION    SQLERRM         WRITE
DECLARE         INTO*           OTHERS          START*          YEAR
DEFAULT*        IS*             OUT             STDDEV          ZONE
DELETE*         ISOLATION


RESERVED WORDS (SQL)
--------------------

SQL Reserved Words have special meaning in SQL, and may not be used for
identifier names unless enclosed in "quotes".

An asterisk (*) indicates words are also ANSI Reserved Words.

Oracle prefixes implicitly generated schema object and subobject names
with "SYS_". To avoid name resolution conflict, Oracle discourages you
from prefixing your schema object and subobject names with "SYS_".

ACCESS          DEFAULT*         INTEGER*        ONLINE          START
ADD*            DELETE*          INTERSECT*      OPTION*         SUCCESSFUL
ALL*            DESC*            INTO*           OR*             SYNONYM
ALTER*          DISTINCT*        IS*             ORDER*          SYSDATE
AND*            DROP*            LEVEL*          PCTFREE         TABLE*
ANY*            ELSE*            LIKE*           PRIOR*          THEN*
AS*             EXCLUSIVE        LOCK            PRIVILEGES*     TO*
ASC*            EXISTS           LONG            PUBLIC*         TRIGGER
AUDIT           FILE             MAXEXTENTS      RAW             UID
BETWEEN*        FLOAT*           MINUS           RENAME          UNION*
BY*             FOR*             MLSLABEL        RESOURCE        UNIQUE*
CHAR*           FROM*            MODE            REVOKE*         UPDATE*
CHECK*          GRANT*           MODIFY          ROW             USER*
CLUSTER         GROUP*           NOAUDIT         ROWID           VALIDATE
COLUMN          HAVING*          NOCOMPRESS      ROWNUM          VALUES*
COMMENT         IDENTIFIED       NOT*            ROWS*           VARCHAR*
COMPRESS        IMMEDIATE*       NOWAIT          SELECT*         VARCHAR2
CONNECT*        IN*              NULL*           SESSION*        VIEW*
CREATE*         INCREMENT        NUMBER          SET*            WHENEVER*
CURRENT*        INDEX            OF*             SHARE           WHERE
DATE*           INITIAL          OFFLINE         SIZE*           WITH*
DECIMAL*        INSERT*          ON*             SMALLINT*


sys@BACKUP>






Datepart in SQL Server And Oracle

SQL Server DATEPART() Function




Syntax :

DATEPART(datepart,date)
datepartAbbreviation
yearyy, yyyy
quarterqq, q
monthmm, m
dayofyeardy, y
daydd, d
weekwk, ww
weekdaydw, w
hourhh
minutemi, n
secondss, s
millisecondms
microsecondmcs
nanosecondns


Examples :
select

Result : 2012
datepart(yyyy,birth_date) from [Table_name]

Oracle : Alternative for DATEPART() Function


SELECT
 SELECT TO_NUMBER(TO_CHAR(SYSDATE, 'HH24')) FROM DUAL
SELECT
current_timestamp,SYSDATE FROM dual
extract(hour FROM current_timestamp) FROM dual

How the ALL keyword works in oracle

Multiset operators combine the results of two nested tables into a single nested table.
The examples related to multiset operators require that two nested tables be created and loaded with data as follows:
First, make a copy of the oe.customers table called customers_demo. We will add the nested table columns to customers_demo.

CREATE TABLE customers_demo AS
  SELECT * FROM customers;
Simple Example :

Condition               Equivalent expression
x > ALL (12)          x > 2
x < ALL (12)          x < 1
x = ALL (12)          (x = 1AND (x = 2)
x <> ALL (12)         (x <> 1AND (x <> 2)


SELECT  * FROM [table_name]
 WHERE  abc_cd < ALL (0097,0098)

Output :

It shows all abc_cd below 97,98


OR

SELECT BankerName, BillingNumber, BillingTotal FROM Billings JOIN Bankers ON Billings.BankerID = Bankers.BankerID
WHERE BillingTotal > ALL
(SELECT BillingTotal
FROM Billings
WHERE BankerID = 34)


Its very simple....try it...

Sunday, 15 July 2012

How to set Page Hits in asp.net [Simple Method]

.Try it.... Happy Coding :):):)


C# :




protected void Page_Load(object sender, EventArgs e)
{
this.countMe();
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/counter.xml"));
lblMsg.Text = ds.Tables[0].Rows[0]["hits"].ToString();
}
private void countMe()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("~/counter.xml"));
int hits = Int32.Parse(ds.Tables[0].Rows[0]["hits"].ToString());
hits += 1;
ds.Tables[0].Rows[0]["hits"] = hits.ToString();
ds.WriteXml(Server.MapPath("~/counter.xml"));
}


ASPX :

...
<div><asp:Label ID="lblMsg" runat="server"></asp:Label></div>
...


Counter.xml

<counter>

<count>
<hits>
1
</hits>
<count>
<counter>

Friday, 13 July 2012

Importing MS Excel data to SQL Server 2008

The Import and Export Wizard

The import and export wizard was available even with SQL 2000 has remained an important tool for exporting from and importing into SQL Server data from many different kinds of data sources. It can also be used for transferring data between non-Microsoft data sources. In this article, an example of transferring an MS Excel spreadsheet data to SQL Server 2008 is described. In any of the transformations it is important to realize that data types used in data sources are not exactly the same and that there are differences to be reckoned with. The basic steps to take are to indicate the source of data and the destination to which it needs to be transferred. In order to match the differences some mappings may be necessary if the source and destination are not both SQL Servers.
The MS Excel file PrincetonTemp.xls used in this example is a simple spread sheet data that shows the temperature variations during a year and the maximum recorded temperature. The data type used for the column ’Month’ is text and of the others are numbers.

Figure 1: PrincetonTemp.xls




Invoke the Import and Export Wizard

Bring up the Import and Export wizard from Start | All Programs | Microsoft SQL Server 2008 | Import and Export Data (32 bit). This pops-up the Welcome Wizard as shown. Make sure you read the explanations provided.

Figure 2: Welcome page of Import and Export Wizard

Choose source of data

Click Next. The default page gets displayed. In the 'Choose a Data Source' page click on the handle along the data source and choose Microsoft Excel file as the data source as shown.

Figure 3: Choosing the source of data



Click Next. The 'Select the source from which to copy data' shows up. Use the Browse...button to bring in the location information of PrincetonTemp.xls to the window as shown. The Excel version displayed by default (Microsoft Excel 97-2003) is proper for the MS Access version used in this article. Keep the 'First row has column names' option checked. Note that the MS Access 2007 is not supported.

Figure 4: Choosing the data file



Choosing the data destination

Click Next. The 'Choose the Destination' page shows up with SQL Server Native Client 10.0 as default and the resident server as Hodentek2\Mysorian. The server is configured for Windows authentication. Accept the defaults. In case your server is configured for SQL Server authentication you need to have the information ready. The database is displaying <default>. Click on the handle and choose a database from the drop-down list. Herein TestNorthwind is chosen. You can choose any database including the tempdb. Note that you can begin to create a new database as well, if you choose to do so by using the New...button.

Figure 5: Choosing SQL Server 2008 as the destination




Copying the table

Click Next. The 'specify the Table Copy or Query' page of the wizard shows up. Since we are transferring only one table, accept the default option, ‘Copy data from one or more tables or views ‘.

Figure 6: Choose option to copy a table



Click Next. Since sheet one has the data place check mark for 'Sheet1$' as shown. Only Sheet1 has data in this XLS file. Modify the destination column to read dbo.PrincetonTemp instead of the default [dbo].[Sheet1$] as shown.

Figure 7: Choosing a sheet from the Workbook


Click Next. In the 'Save and Run Package' page of the wizard accept the defaults shown. You could also save it as a package as well for later use.

Figure 8: Choose ‘run’ immediately option



Click Next. The 'Complete the Wizard' page gets displayed. Check if the information is correct (this is a summary of options you have chosen). If it is not correct you can hit the back button and move back to the pages you visited earlier in the reverse order.

Figure 9: The completed wizard



Click Finish. The program starts running and you should see a progress window displaying 'Performing Operation...' as shown.

When the operation is completed you should see the following window and you can keep a copy of the report as to how the import was executed using the Report drop-down button.

Figure 11: Successful execution of transfer


The import in this case was successful as shown above. If there is an error there should be a hyperlink to the message in the Message column of the above window, presently the message is ’12 rows transferred’. Close the wizard. The transfer is finished.

Verifying the import

Open the Microsoft SQL Server Management Studio and login to display the database engine using your Windows credentials. Expand the databases node and the TestNorthwind database node as shown.

Figure 12: A new table in the database





Data type mismatch and the fix

Also check if the data is brought in correctly as shown by right clicking the dbo.PrincetonTemp table and choose 'Select Top 1000 rows'. You can see that the Month names are all showing 'Null'. The ‘text’ data type in the XLS file became nvarchar type.

Figure 13: Null data in the ‘Month’ column

How to insert data from one table to another table in SQL/Oracle

Method 1 : INSERT INTO SELECTThis method is used when table is already created in the database earlier and data is to be inserted into this table from another table. If columns listed in insert clause and select clause are same, they are are not required to list them. I always list them for readability and scalability purpose.
USE AdventureWorks
GO
----Create TestTableCREATE TABLE TestTable (FirstName VARCHAR(100), LastName VARCHAR(100))----INSERT INTO TestTable using SELECTINSERT INTO TestTable (FirstName, LastName)SELECT FirstName, LastNameFROM Person.ContactWHERE EmailPromotion = 2----Verify that Data in TestTableSELECT FirstName, LastNameFROM TestTable----Clean Up DatabaseDROP TABLE TestTable
GO

Method 2 : SELECT INTO
This method is used when table is not created earlier and needs to be created when data from one table is to be inserted into newly created table from another table. New table is created with same data types as selected columns.
USE AdventureWorks
GO
----Create new table and insert into table using SELECT INSERTSELECT FirstName, LastNameINTO TestTableFROM Person.ContactWHERE EmailPromotion = 2----Verify that Data in TestTableSELECT FirstName, LastNameFROM TestTable----Clean Up DatabaseDROP TABLE TestTable
GO



More Details

Synonyms in Oracle

A synonym is an alias for one of the following objects:
  • table
  • object table
  • view
  • object view
  • sequence
  • stored procedure
  • stored function
  • package
  • materialized view
  • java class
  • used defined object object type
  • another synonym
The object does not need to exist at the time of its creation.
How to create synonyms ?


CREATE

SYNONYM  table_name  FOR table_name
 
How to display list of all synonyms from database ?

SELECT
 ORDER BY 1,2
'SYNONYM:',synonym_name,table_owner FROM USER_SYNONYMS


or

SELECT * FROM ALL_SYNONYMS

Thursday, 12 July 2012

how to use ViewState in asp.net

asp.net ViewState example: how to use ViewState in asp.net 

aspx :
 
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    <asp:Label ID="lblCount" runat="server" Text=""></asp:Label>
    <br />
    <br />
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </form>
</body>

 
 c# :

 protected void Button1_Click(object sender, EventArgs e)
        {
            int count = 1;
            if (ViewState["count"] == null)
            {
                count = 1;
            }
            else
            {
                count = (int)ViewState["count"] + 1;
            }
            ViewState["count"] = count;
            lblCount.Text = "Count = " + count;
        }




 

Wednesday, 11 July 2012

HOW TO DISPLY MESSEGE WHEN CAPS LOCK IS ON IN LOGIN PAGE

IN ASPX PAGE  JAVA SCRIPT :
 

 
<script language="javascript" type="text/javascript">
function capLock(e){
 kc = e.keyCode?e.keyCode:e.which;
 sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false);
 if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk))
  document.getElementById('divMayus').style.visibility = 'visible';
 else
  document.getElementById('divMayus').style.visibility = 'hidden';
 
  }
 
</script>
 
//THIS IS THE DIV THAT WILL DISPLAYED ON CAPS LOCK ON..
<div id="divMayus" style="visibility:hidden">
           <asp:Label ID="Label1" runat="server" Text="Caps Lock is On.!"></asp:Label>
</div>
 
//THIS IS THE TEXT BOX AT WHICH U WANT TO CALL JAVASCTIPT..
<asp:TextBox ID="txtPassword" runat="server"  TextMode="Password" onkeypress="capLock(event)">
</asp:TextBox>


//FOR ANIMATION WITH BALOON POPUP CONTROL USING AJAX

 <ajaxtoolkit:balloonpopupextender id="PopupControlExtender2" runat="server" 
targetcontrolid="txtPwd"
 balloonpopupcontrolid="txtPwd" position="BottomRight" balloonstyle="Cloud" balloonsize="Small"
customcssurl="CustomStyle/BalloonPopupOvalStyle.css" customclassname="oval" useshadow="true"
scrollbars="Auto" displayonmouseover="true" displayonfocus="false" displayonclick="true" />

Tuesday, 10 July 2012

UpdatePanel in ASP.NET

ASPX :


<body>
    <form id="form1" runat="server">
      <div style="padding-top: 10px">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <fieldset>
                <legend>UpdatePanel</legend>
                <asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
                </fieldset>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        </div>

    </div>

    </form>
</body>


If you are using MASTER PAGE IN PROJECT ...Then you need ScriptManagerProxy 

You need only copy & paste of following two line with your <asp:Content> tag
 
<asp:ScriptManagerProxy ID="scriptmanagerproxy1" runat="server">
        </asp:ScriptManagerProxy>


C#:

protected void Button1_Click(object sender, EventArgs e)
        {
            Label1.Text = "Refreshed at " +
            DateTime.Now.ToString();
        }