Yasserzaid’s Weblog

December 17, 2008

Watermark with TextBox using CSS

Filed under: CSS — yasserzaid @ 10:47 pm

Try this example:

.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>Untitled Page</title>
    <style type=”text/css”>
    .inactiveSearchBox
{
    background-color: #f0f0f0;
    border: solid 1px #ffffff;
}

.activeSearchBox
{
    border: groove 1px #d9d9d9;
    background-color: #ffffff;
}
    </style>
</head>
<body>
    <form id=”form1″ runat=”server”>
    <div>
        With Input :<input type=”text” class=”inactiveSearchBox” id=”SearchStrng”
   value=” Search Here”
   onFocus=”this.className=’activeSearchBox’; if(this.value==’ Search Here’)this.value=”;”
   onBlur=”if(this.value==”)this.value=’ Search Here’;this.className=’inactiveSearchBox’;” />
        <br />
        <br />
        With TextBox :
        <asp:TextBox ID=”TextBox1″ runat=”server” CssClass=”inactiveSearchBox” Text=” Search Here”
   onFocus=”this.className=’activeSearchBox’; if(this.value==’ Search Here’)this.value=”;”
   onBlur=”if(this.value==”)this.value=’ Search Here’;this.className=’inactiveSearchBox’;” ></asp:TextBox></div>
    </form>
</body>
</html>

Good Luck

Add Auto Numbering with DataList and Gridview

Filed under: ASP.Net — yasserzaid @ 10:45 pm

Try this example:

http://blog.krisvandermast.com/AutonumberingASPNETGridControls.aspx

 

with dataList

<asp:TemplateColumn>

       <ItemTemplate>

            <%# Container.DataSetIndex + 1 %>

       </ItemTemplate>

</asp:TemplateColumn>

with GridView

<asp:TemplateField>

   <ItemTemplate>

      <%# Container.DataItemIndex + 1 %>

   </ItemTemplate>

</asp:TemplateField>
//——- or ————-

<asp:TemplateField HeaderText=”Sl. No.” HeaderStyle-Font-Bold=”true” HeaderStyle-ForeColor=”Black”>

<ItemTemplate>

<%# ( ( ( GridView ) ( ( GridViewRow ) Container ).Parent.Parent ).PageIndex )*( ( GridView ) ( ( GridViewRow ) Container ).Parent.Parent ).PageSize+Container.DataItemIndex+1 %>
</ItemTemplate>

</asp:TemplateField>

Good Luck

Custom validator for Group of RadioButtons

Filed under: ASP.Net, Javascript — yasserzaid @ 10:41 pm

Try this example:

<script type=”text/javascript”>

function ValidateRadios(oSrc, args)
{

var rpta = false;for(i = 1; i<=5 ; i++)
{

if(document.getElementById(“loc” + i).checked == true)
{

rpta = true;
}

}

args.IsValid = rpta;

}

</script>

<asp:RadioButton ID=”loc1″ runat=”server” ValidationGroup=”location” />

<asp:RadioButton ID=”loc2″ runat=”server” ValidationGroup=”location” />

<asp:RadioButton ID=”loc3″ runat=”server” ValidationGroup=”location” />

<asp:RadioButton ID=”loc4″ runat=”server” ValidationGroup=”location” />

<asp:RadioButton ID=”loc5″ runat=”server” ValidationGroup=”location” />

<asp:Button ID=”Button1″ ValidationGroup=”location” runat=”server” Text=”Button” />

<br />

<asp:CustomValidator ID=”CustomValidator1″ runat=”server” ValidationGroup=”location”
ErrorMessage=”Please select one of the radio button”
ClientValidationFunction=”ValidateRadios” Display=”Dynamic” OnServerValidate=”validateLoc” ></asp:CustomValidator>

Good Luck

Insert New Record with Gridview

Filed under: ASP.Net — yasserzaid @ 8:38 pm

Try this example:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=107

Tip 1: Add, Update, Delete Records in a Gridview using SqlDataSource
By default, the GridView control doesn’t have support for inserting new records. However you can use the built-in edit or delete functionality of the GridView control. Let us explore how to insert new records and Update and Delete existing records in Gridview. Just copy and paste the code in your project. We will be using the ‘Categories’ table in the ‘Northwind’ database.
GridView.aspx
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”GridView.aspx.cs” Inherits=”GridView” %>
 
<!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>Grid View Add Update Delete</title>
</head>
<body>
    <form id=”form1″ runat=”server”>
    <div>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False” DataKeyNames=”CategoryID”
            DataSourceID=”SqlDataSource1″ ShowFooter=”true” AllowPaging=”True” AllowSorting=”True” OnRowCommand=”GridView1_RowCommand”>
            <Columns>
           
                <asp:CommandField ShowDeleteButton=”True” ShowEditButton=”True”/>               
                <asp:TemplateField HeaderText=”CategoryID” InsertVisible=”False” SortExpression=”CategoryID”>
                    <EditItemTemplate>
                        <asp:Label ID=”Label1″ runat=”server” Text=’<%# Eval(“CategoryID”) %>’></asp:Label>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID=”Label1″ runat=”server” Text=’<%# Bind(“CategoryID”) %>’></asp:Label>
                    </ItemTemplate>                  
                </asp:TemplateField>
                <asp:TemplateField HeaderText=”CategoryName” SortExpression=”CategoryName”>
                    <EditItemTemplate>
                        <asp:TextBox ID=”TextBox1″ runat=”server” Text=’<%# Bind(“CategoryName”) %>’></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID=”Label2″ runat=”server” Text=’<%# Bind(“CategoryName”) %>’></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID=”CategoryNameTextBox” Runat=”server”></asp:TextBox>
                        </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText=”Description” SortExpression=”Description”>
                    <EditItemTemplate>
                        <asp:TextBox ID=”TextBox2″ runat=”server” Text=’<%# Bind(“Description”) %>’></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID=”Label3″ runat=”server” Text=’<%# Bind(“Description”) %>’></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:TextBox ID=”DescriptionTextBox” Runat=”server”></asp:TextBox>
                    </FooterTemplate>                 
                </asp:TemplateField>
                <asp:templatefield>                  
                        <footertemplate>
                              <asp:linkbutton id=”btnNew” runat=”server” commandname=”New” text=”New” />
                        </footertemplate>
                  </asp:templatefield>
               
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID=”SqlDataSource1″ runat=”server” ConnectionString=”Data Source=SUPROTIM;Initial Catalog=Northwind;Integrated Security=True”
            DeleteCommand=”DELETE FROM [Categories] WHERE [CategoryID] = @CategoryID” InsertCommand=”INSERT INTO [Categories] ([CategoryName], [Description]) VALUES (@CategoryName, @Description)”
            ProviderName=”System.Data.SqlClient” SelectCommand=”SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]“
            UpdateCommand=”UPDATE [Categories] SET [CategoryName] = @CategoryName, [Description] = @Description WHERE [CategoryID] = @CategoryID”>
            <DeleteParameters>
                <asp: Parameter Name=”CategoryID” Type=”Int32″ />
            </DeleteParameters>
            <UpdateParameters>
                <asp: Parameter Name=”CategoryName” Type=”String” />
                <asp: Parameter Name=”Description” Type=”String” />
                <asp: Parameter Name=”CategoryID” Type=”Int32″ />
            </UpdateParameters>
            <InsertParameters>
                <asp: Parameter Name=”CategoryName” Type=”String” />
                <asp: Parameter Name=”Description” Type=”String” />
            </InsertParameters>
        </asp:SqlDataSource>
   
    </div>
    </form>
</body>
</html>
 
GridView.aspx.cs
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        SqlConnection conn = new SqlConnection(
                    ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        try
        {
            if (e.CommandName.Equals(“New”))
            {
                LinkButton btnNew = e.CommandSource as LinkButton;
                GridViewRow row = btnNew.NamingContainer as GridViewRow;
                if (row == null)
                {
                    return;
                }
                TextBox txtCatName = row.FindControl(“CategoryNameTextBox”) as TextBox;
                TextBox txtDescription = row.FindControl(“DescriptionTextBox”) as TextBox;               
                SqlCommand cmd = new SqlCommand(
                    “INSERT INTO [Categories] ([CategoryName], [Description]) VALUES (@CategoryName, @Description)”,
                    conn);
                cmd.Parameters.AddWithValue(“CategoryName”, txtCatName.Text);
                cmd.Parameters.AddWithValue(“Description”,txtDescription.Text);
                conn.Open();
                if (cmd.ExecuteNonQuery() == 1)
                {
                    GridView1.DataBind();
                }
            }
        }
        catch (Exception ex)
        {
 
        }
        finally
        {
            conn.Close();
        }
    }

Web.config

<connectionStrings>
            <addname=”NorthwindConnectionString”connectionString=”Data Source =.;Integrated Security = SSPI; Initial Catalog=Northwind;”/>
           
</connectionStrings>
 
Tip 2: Paging and Sorting a GridView without Refreshing a Page
If you have created a GridView and have bound it to a data source control, you can avoid postback during sorting and paging by setting  ‘EnableSortingAndPagingCallbacks’ property of the GridView to True.
Just remember that when you set the ‘EnableSortingAndPagingCallbacks’ property to true, you cannot use Template Fields in the GridView.
 
Tip 3: Pop-up a Confirmation box before Deleting a row in GridView
Add a template field and drop a button in it, using which the user will delete the record. In the OnClientClick event, call the confirm() function as mentioned below:
<asp:TemplateField>
      <ItemTemplate>
        <asp:Button ID=”btnDel” runat=”server” Text=”Delete”
            CommandName=”Delete” OnClientClick=”return confirm(‘Are you sure you want to delete the record?’);” />
      </ItemTemplate>
</asp:TemplateField>
 
Tip 4: Display details of the Row selected in the GridView
Assuming you have a button called ‘Select’ in your GridView with CommandName ‘Select’, to find out the row clicked and display the row’s details, use this code:
C#
private void GridView1_RowCommand(Object sender,
GridViewCommandEventArgs e)
    {
        if (e.CommandName == “Select”)
        {
            int idx = Convert.ToInt32(e.CommandArgument);
            GridViewRow selrow = GridView1.Rows[idx];
            string fstCell  = selrow.Cells[0].Text;
string scndCell = selrow.Cells[1].Text;
// and so on
// Thanks to Mark Rae (MVP) for pointing the typo. Earlier it was Cells[1] and Cells [2]
        }
    }

 
Tip 5: Retrieve Details of the Row being Modified in GridView
C#
void GridView1_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
    {
        // Retrieve the row being edited.
        int index = GridView1.EditIndex;
        GridViewRow row = GridView1.Rows[index];
 
        // Retrieve the value of the first cell
        lblMsg.Text = “Updated record ” + row.Cells[1].Text;
    }

 
Tip 6: Retrieve Details of the Row being Deleted in GridView
The ID of the row being deleted must be in the GridView.DataKeyNames collection.
C#
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int ID = (int)GridView1.DataKeys[e.RowIndex].Value;
        // Query the database and get the values based on the ID
    }
 
Tip 7: Cancelling Update and Delete in a GridView
RowUpdating – Occurs when a row’s Update button is clicked, but before the GridView control updates the row.
RowDeleting – Occurs when a row’s Delete button is clicked, but before the GridView control deletes the row.
C#
protected void gvDetail_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        e.Cancel = true;
    }
void GridView1_RowDeleting(Object sender, GridViewDeleteEventArgs e)
    {
        // Check for a condition and cancel the delete
        // There should be atleast one row left in the GridView
        if (GridView1.Rows.Count <= 1)
        {
            e.Cancel = true;
        }
    }

 
Tip 8: Paging and Sorting in GridView without using Datasource control

C#
<asp:GridView ID=”gridView” OnPageIndexChanging=”gridView_PageIndexChanging”
OnSorting=”gridView_Sorting” runat=”server” />
private string ConvertSortDirectionToSql(SortDirection sortDireciton)
{
   string newSortDirection = String.Empty;
   switch (sortDirection)
   {
      case SortDirection.Ascending:
         newSortDirection = “ASC”;
         break;
      case SortDirection.Descending:
         newSortDirection = “DESC”;
         break;
   }
   return newSortDirection
}
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
   gridView.PageIndex = e.NewPageIndex;
   gridView.DataBind();
}
protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
{
   DataTable dataTable = gridView.DataSource as DataTable;
   if (dataTable != null)
   {
      DataView dataView = new DataView(dataTable);
      dataView.Sort = e.SortExpression + ” ” + ConvertSortDirectionToSql(e.SortDirection);
      gridView.DataSource = dataView;
      gridView.DataBind();
   }
}

  
Tip 9: Export GridView To Excel


C#
protected void Button1_Click(object sender, EventArgs e)
    {
        Response.AddHeader(“content-disposition”, “attachment;filename=FileName.xls”);
        Response.Charset = String.Empty;
        Response.ContentType = “application/vnd.xls”;
        System.IO.StringWriter sw = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
        GridView1.RenderControl(hw);
        Response.Write(sw.ToString());
        Response.End();
    }

Good Luck

Make This Site Your Home Page Button

Filed under: Javascript — yasserzaid @ 8:34 pm

Try this :

<INPUT TYPE=”button” VALUE=”Make This Site Your Home Page” onClick=”this.style.behavior=’url(#default#homepage)’; this.setHomePage(‘Page URL beginning with http:// here’);”>
//———– For FireFox ————–\\

http://forums.asp.net/t/1279376.aspx

<script language=”javascript”>
function setHomepage()
{
 if (document.all)
    {
        document.body.style.behavior=’url(#default#homepage)’;
  document.body.setHomePage(‘http://www.asp.net/130.aspx’);
 
    }
    else if (window.sidebar)
    {
    if(window.netscape)
    {
         try
   { 
            netscape.security.PrivilegeManager.enablePrivilege(“UniversalXPConnect”); 
         } 
         catch(e) 
         { 
            alert(“this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true”); 
         }
    }
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref(‘browser.startup.homepage’,'http://www.asp.net/130.aspx’);
 }
}
</script>
<input type=”button” value=”set home page” onclick=”setHomepage();” />

Good Luck

Master Page Template (3)

Filed under: CSS — yasserzaid @ 8:32 pm

Try this:

http://www.devarticles.com/c/a/Web-Style-Sheets/DIV-Based-Layout-with-CSS/4/

 

<style type=”text/css”>
<!–
#header {
  background: #0f0;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 800px;
  height: 100px;
}
#leftcol {
  background: #f00;
  position: absolute;
  top: 100px;
left: 0px;
  width: 150px;
  height: 500px;
}
#rightcol {
  background: #f00;
  position: absolute;
  top: 100px;
left: 650px;
  width: 150px;
  height: 500px;
}
#content {
  background: #fff;
  position: absolute;
  top: 100px;
left: 150px;
  width: 500px;
  height: 500px;
}
#footer {
  background: #0f0;
  position: absolute;
  top: 500px;
  left: 0px;
  width: 800px;
  height: 100px;
}
–>
</style>

The HTML code is the following:

<div id=”header”>Header Section</div>
<div id=”leftcol”>Left Section</div>
<div id=”content”>Content Section</div>
<div id=”rightcol”>Right Section</div>
<div id=”footer”>Footer Section</div>

Here is the complete code:

<html>
<head>
<title>THREE-COLUMN FIXED LAYOUT WITH FIXED BOXES</title>
<style type=”text/css”>
<!–
#header {
  background: #0f0;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 800px;
  height: 100px;
}
#leftcol {
  background: #f00;
  position: absolute;
  top: 100px;
  left: 0px;
  width: 150px;
  height: 500px;
}
#rightcol {
  background: #f00;
  position: absolute;
  left: 650px;
  top: 100px;
  width: 150px;
  height: 500px;
}
#content {
  background: #fff;
  position: absolute;
  top: 100px;
left: 150px;
  width: 500px;
  height: 500px;
}
#footer {
  background: #0f0;
  position: absolute;
  top: 500px;
  left: 0px;
  width: 800px;
  height: 100px;
}
–>
</style>
</head>
<body>
<div id=”header”>Header Section</div>
<div id=”leftcol”>Left Section</div>
<div id=”content”>Content Section</div>
<div id=”rightcol”>Right Section</div>
<div id=”footer”>Footer Section</div>
</body>
</html>

Good Luck

Master Page Template (2)

Filed under: CSS — yasserzaid @ 8:30 pm

Try this:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html>
<head>
    <title>lance</title>
    <style>
        .up1
        {
            overflow: hidden;
            height: 1px;
            margin-left: 4px;
            margin-right: 4px;
            background-color: Aqua;
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .up2
        {
            overflow: hidden;
            height: 1px;
            margin-left: 3px;
            margin-right: 3px;
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .up3
        {
            overflow: hidden;
            height: 1px;
            margin-left: 2px;
            margin-right: 2px;
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .content
        {
            margin-left: 1px;
            margin-right: 1px;
            height: 100px; /*height*/ /*background-color: Aqua;*/
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .down1
        {
            overflow: hidden;
            height: 1px;
            margin-left: 2px;
            margin-right: 2px;
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .down2
        {
            overflow: hidden;
            height: 1px;
            margin-left: 3px;
            margin-right: 3px;
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .down3
        {
            overflow: hidden;
            height: 1px;
            margin-left: 4px;
            margin-right: 4px;
            background-color: Aqua;
            border-left: solid 1px Aqua;
            border-right: solid 1px Aqua;
        }
        .cell
        {
            width: 50px; /*width*/
        }
    </style>
</head>
<body>
    <div class=”cell”>
        <div class=”up1″>
        </div>
        <div class=”up2″>
        </div>
        <div class=”up3″>
        </div>
        <div class=”content”>
            //your content
        </div>
        <div class=”down1″>
        </div>
        <div class=”down2″>
        </div>
        <div class=”down3″>
        </div>
    </div>
</body>
</html>

Good Luck

Master Page Template (1)

Filed under: CSS — yasserzaid @ 8:28 pm

Try this:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html>
<head>
    <title></title>

    <script type=”text/javascript”>
      function doResize()
      {
           document.getElementById(“box-contents”).style.height=(document.documentElement.clientHeight-60)+”px”;
      }
      window.onresize = doResize;
    </script>

    <style type=”text/css”>
        body
        {
            background-color: black;
            margin: 0px;
            padding: 0px;
            color: White;
            font: 16px arial;
        }
        #content
        {
            margin: auto;
            width: 780px;
            height: 100%;
            padding: 0 0;
        }
        div.rounded-box
        {
            position: relative;
            background-color: red;
            margin: 3px;
            width: 780px;
            padding: 0 0;
        }
        /*********************
GLOBAL ATTRIBUTES
*********************/div.top-left-corner, div.bottom-left-corner, div.top-right-corner, div.bottom-right-corner
        {
            position: absolute;
            width: 20px;
            height: 20px;
            background-color: black;
            overflow: hidden;
        }
        div.top-left-inside, div.bottom-left-inside, div.top-right-inside, div.bottom-right-inside
        {
            position: relative;
            font-size: 150px;
            font-family: arial;
            color: red;
            line-height: 40px;
        }
        /*********************
SPECIFIC ATTRIBUTES
*********************/div.top-left-corner
        {
            top: 0px;
            left: 0px;
        }
        div.bottom-left-corner
        {
            bottom: 0px;
            left: 0px;
        }
        div.top-right-corner
        {
            top: 0px;
            right: 0px;
        }
        div.bottom-right-corner
        {
            bottom: 0px;
            right: 0px;
        }
        div.top-left-inside
        {
            left: -8px;
        }
        div.bottom-left-inside
        {
            left: -8px;
            top: -17px;
        }
        div.top-right-inside
        {
            left: -25px;
        }
        div.bottom-right-inside
        {
            left: -25px;
            top: -17px;
        }
        div.box-contents
        {
            position: relative;
            padding: 8px;
            color: white;
        }
    </style>
</head>
<body onload=”doResize();”>
    <div id=”content”>
        <span>Header</span>
        <div class=”rounded-box”>
            <div class=”top-left-corner”>
                <div class=”top-left-inside”>
                    •</div>
            </div>
            <div class=”bottom-left-corner”>
                <div class=”bottom-left-inside”>
                    •</div>
            </div>
            <div class=”top-right-corner”>
                <div class=”top-right-inside”>
                    •</div>
            </div>
            <div class=”bottom-right-corner”>
                <div class=”bottom-right-inside”>
                    •</div>
            </div>
            <div class=”box-contents” id=”box-contents”>
                Contents go here, but it must be at least two lines to look any good.
                <br>
                Contents go here, but it must be at least two lines to look any good.
                <br>
                Contents go here, but it must be at least two lines to look any good.
                <br>
            </div>
            <!– end div.box-contents –>
        </div>
        <!– end div.rounded-box –>
        <span>Footer</span>
    </div>
</body>
</html>

Good Luck

How to check if a date is valid

Filed under: ASP.Net — yasserzaid @ 8:15 pm

Hi

check this link

http://articles.techrepublic.com.com/5100-10878_11-5794617.html

http://forums.asp.net/p/1189129/2038164.aspx

or try this to validate date:

<asp:CompareValidator id=“dateValidator” runat=“server” Type=“Date” Operator=“DataTypeCheck” ControlToValidate=“dateTextbox” ErrorMessage=“Please enter a valid date (MM/dd/yyyy) format.”></asp:CompareValidator>

Good Luck

Prevent Login twice

Filed under: ASP.Net — yasserzaid @ 8:04 pm

Hi

try this example:

protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{

e.Cancel = Membership.GetUser(Login1.UserName).IsOnline;
}
//————-Another way —————
<asp:Login ID=”Login1″ runat=”server” BackColor=”#FFFBD6″ BorderColor=”#FFDFAD” BorderStyle=”Solid”
                BorderWidth=”1px” Font-Names=”Verdana” Font-Size=”10pt”
                ForeColor=”#333333″ Visible=”False” Width=”372px” OnLoggingIn=”Login1_LoggingIn”>
                <TitleTextStyle BackColor=”#990000″ Font-Bold=”True” ForeColor=”White” />
                <LoginButtonStyle BackColor=”White” BorderColor=”#CC9966″ BorderStyle=”Solid” BorderWidth=”1px”
                    Font-Names=”Verdana” ForeColor=”#990000″ />
            </asp:Login>

 
protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
    {
        e.Cancel = Membership.GetUser(Login1.UserName).IsOnline;
    }

Good luck

Older Posts »

Blog at WordPress.com.