Tuesday, March 9, 2010

Use of PostBackUrl in ASP.NET 2.0

MyPage.aspx:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>My Page</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <table cellpadding="0" cellspacing="0" border="2" height="50px" style="width: 33%">
        <tr>
          <td align="center" valign="top" style="padding-top:20px;">
            <asp:TextBox ID="TxtName" runat="server"></asp:TextBox><br/><br/>
            <asp:Button ID="BtnSubmit" runat="server" PostBackUrl="http://www.codeanswer.blogspot.com" Text="Submit" OnClick="Button1_Click" />
          </td>
        </tr>
      </table>
    </div>
  </form>
</body>
</html>

When you post to another page in ASP.NET 2.0, you can reach out to the values in the page using the following methods:

MyPage.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {}
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (PreviousPage != null)
        {
            TextBox txtName = (TextBox)
            PreviousPage.FindControl("txtName");
            this.TxtName.Text= txtName.Text;
        }
    }
}

How to merge the data of two table in a DataGrid

or showing the data of two table in a dataGrid make sure that the field name and field type of both table should be same. 

The aspx code is: <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Merge Two DataSet</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <table width="70%" align="center" border="4">
        <tr><td height="20px"></td></tr>
        <tr><td align="center">
               <asp:DataGrid ID="GridAllRecord" runat="server" HeaderStyle-BackColor="blue">
               </asp:DataGrid>   
         <tr><td height="20px"></td></tr>
         </td></tr>
      </table>  
    </div>
    </form>
</body>
</html>The aspx.cs code

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection con;
    SqlDataAdapter da;  
    DataSet ds1 = new DataSet();
    DataSet ds2 = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        binddata();
    }

   public void binddata()
   {
       con=new SqlConnection("Data Source=MCN101; Initial Catalog=MergeTable; Uid=sa; pwd=");
       da = new SqlDataAdapter("Select * from Table1", con);
       da.Fill(ds1, "Record");
       da = new SqlDataAdapter("select * from Table2", con);
       da.Fill(ds2, "Record");
       ds1.Merge(ds2);
       GridAllRecord.DataSource = ds1;
       GridAllRecord.DataBind();
   } 
}

Home » ASP.NET 2.0/3.5 » DropShadow AJAX Control DropShadow AJAX Control

DropShadow is an extender which applies a "Drop Shadow" to a Panel. It allows you to specify how wide the shadow is as well as how opaque it is, or if you would like rounded corners.
<ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" Opacity="0.50" TargetControlID="Image1" TrackPosition="True" Width="8"/>

Properties of Drop shadow:
  • TargetControlID - The ID of the button or link for this extender to operate on
  • Width - The width, in pixels of the drop shadow. Default value is 5.
  • Opacity - The opacity of the drop shadow, from 0 (fully transparent) to 1.0 (fully opaque). The default value is .5.
  • TrackPosition - Whether the drop shadow should track the position of the panel it is attached to. Use this if the panel is absolutely positioned or will otherwise move.
  • Rounded - Set to true to set rounded corners on the target and the shadow. Default is false.
Example:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropShadow.aspx.cs" Inherits="DropShadow" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<html xmlns="http://www.w3.org/1999/xhtml">
    <
head runat="server">
        <
title>AJAX DropShadow</title>
    </
head>
    <
body>
        <
form id="form1" runat="server">
            <
div>
                <
table width="100%" cellpadding="5" cellspacing="5">
                    <
tr>
                        <
td>
                            <
asp:ScriptManager ID="ScriptManager1" runat="server" />
                            <
asp:Panel ID="Panel1" runat="server">
                                <
asp:TextBox ID="TextBox1" runat="server" Width="125px" Visible="false"></asp:TextBox>
                                <
ajaxToolkit:SliderExtender ID="SliderExtender1" runat="server" TargetControlID="TextBox1" />
                                <
asp:Image ID="Image1" runat="server" Height="200" Width="200" ImageUrl="~/Image1.jpg" />
                            </
asp:Panel>
                            <
ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" Opacity="0.50" TargetControlID="Image1" TrackPosition="True" Width="8">
                            </
ajaxToolkit:DropShadowExtender>
                        </
td>
                    </
tr>
                </
table>
            </
div>
        </
form>
    </
body>
</
html>

When you use property Rounded=true like as follows:
 <ajaxToolkit:DropShadowExtender ID="DropShadowExtender1" runat="server" Rounded=true Radius=8
Opacity="0.50" TargetControlID="Image1" TrackPosition="True" Width="8">
</
ajaxToolkit:DropShadowExtender>

Repeater control:

The Repeater control is used to display the data items in representing list. The content and layout of list items in Repeater is defined using Templates. Every Repeater must define an ItemTemplate.
Template:
There are the following Templates used in repeater control.
    * AlternatingItemTemplate
    * FooterTemplate
    * HeaderTemplate
    * ItemTemplate
    * SeparatorTemplate
FooterTemplate: The FooterTemplate determines the content and layout of the list footer. It is used to specify an optional footer row.
For Example:
<footertemplate></footertemplate>
HeaderTemplate: The HeaderTemplate determines the content and layout of the list header. It is used to specify an optional header row.
For Example:
<HeaderTemplate>
  <tr>
    <td><b>name</b></td>
    <td><b>no</b></td>
    <td><b>subject</b></td>
 </tr>
</HeaderTemplate>
ItemTemplate: It defines the content and layout of items within the list.
For Example:
<ItemTemplate>
  <tr>
    <td><%# DataBinder.Eval(Container,"dataitem.name") %></td>
    <td><%# DataBinder.Eval(Container,"dataitem.no") %></td>
    <td><%# DataBinder.Eval(Container,"dataitem.subject") %></td>
  </tr>
</ItemTemplate>

AlternatingItemTemplate: It is used as follows:
For Example:
<AlternatingItemTemplate>
  <tr style="background-color:Yellow">
  <td><%# DataBinder.Eval(Container,"dataitem.name") %></td>Soldier of Love
    <td><%# DataBinder.Eval(Container,"dataitem.no") %></td>
    <td><%# DataBinder.Eval(Container,"dataitem.subject") %></td>
  </tr>
</AlternatingItemTemplate>

Default.aspx file:  

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="repeater1_itemcomand">
       <HeaderTemplate>
        <table border=5>
        <tr>
         <td><b>Roll no</b></td>
         <td><b>Name</b></td>
         <td><b>Course</b></td>
        </tr>
       </HeaderTemplate>
       <ItemTemplate>
        <tr>
        <td><%# DataBinder.Eval(Container,"DataItem.Rollno") %></td>
        <td><%# DataBinder.Eval(Container,"dataitem.Name") %></td>
        <td><%# DataBinder.Eval(Container,"dataitem.Course") %></td>
        </tr>
       </ItemTemplate>
       <AlternatingItemTemplate>
        <tr style="background-color:Yellow">
        <td><%# DataBinder.Eval(Container,"DataItem.Rollno") %></td>
        <td><%# DataBinder.Eval(Container,"dataitem.Name") %></td>
        <td><%# DataBinder.Eval(Container,"dataitem.Course") %></td>
        </tr>
       </AlternatingItemTemplate>
       <FooterTemplate></table></FooterTemplate>      
       </asp:Repeater>
    </div>
    </form>
</body>
</html>

Default.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
    SqlConnection con;
    SqlCommand com = new SqlCommand();
    protected void Page_Load(object sender, EventArgs e)
    {
     con = new SqlConnection("Data Source=MCN004;Initial Catalog=student; uid=sa;pwd=");
    com.Connection = con;
    com.CommandText = "select * from student";
    con.Open();
    Repeater1.DataSource= com.ExecuteReader();
    Repeater1.DataBind();
    con.Close();
    }
    protected void repeater1_itemcomand(object source, RepeaterCommandEventArgs e)
    {}
}


 



paid to drive website

paid to drive website: "ar as well as offering an additional pr"