Archive

Archive for November, 2011

Get All Logged in Users using Membership

November 17, 2011 Leave a comment

Hi all,

try this example to Get All logged in users using Membership :-

First Add Gridview Control in your page and in code behind add this code which will bind Gridview to Online Users :-

  ArrayList list = new ArrayList();
        MembershipUserCollection allUsers = Membership.GetAllUsers();
        MembershipUserCollection filteredUsers = new MembershipUserCollection(); 
        bool isOnline = true;
        foreach (MembershipUser user in allUsers)
        {
            // if user is currently online, add to gridview list
            if (user.IsOnline == isOnline)
            {
                filteredUsers.Add(user);
                list.Add(user);
            } 
            gvwonlineusers.DataSource = list;
            gvwonlineusers.DataBind();
        }

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net

Find Control In Gridview RowCommand Event

November 13, 2011 1 comment

Hi all,

try this example to Find Control In Gridview RowCommand Event

<asp:TemplateField HeaderText="Address">
    <ItemTemplate>
        <asp:Label ID="lbl_bs_id" runat="server" Text='<%# Bind("bs_id") %>' CssClass="hidelbl"></asp:Label>
    </ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Show">
    <ItemTemplate>
         <asp:ImageButton ID="ibtn_show" runat="server" AlternateText="Show" CausesValidation="False"
CommandName="Show" ImageUrl="~/Images/show.jpg" />
    </ItemTemplate>
</asp:TemplateField>

in code behind :-


protected void GV_MainBuses_RowCommand(object sender, GridViewCommandEventArgs e)
 {
   if (e.CommandName == "Show")
   {
     GridViewRow gvRow = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
     Label lbl_bs_id = (Label)gvRow.FindControl("lbl_bs_id");
     Response.Write(lbl_bs_id.Text);

   }
 }

Hope this helps

Good Luck

Categories: ASP.Net

JQuery Slider with ASP.Net

November 11, 2011 Leave a comment

Hi all,

try this Example to use JQuery Slider with ASP.Net


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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>
    <link type="text/css" rel="Stylesheet"href="jquery-ui.css" />
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="jquery-ui.min.js"></script>

<script type="text/javascript">
  $(document).ready(function(){
  $("#slider").slider(
  {
    min:0,
    max:250,
    step:5,
    slide:function(event,ui)
    {
      $('#<%= lbl_No.ClientID %>').text(ui.value);
    }
  });
});
  </script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="slider" style='width:300px'></div>
        <asp:Label ID="lbl_No" runat="server" Text="0"></asp:Label>
    </form>
</body>
</html>

Hope this helps

Good Luck

Categories: ASP.Net, Jquery

Use JQuery Notification Plugin with ASP.Net

November 9, 2011 1 comment

Hi all,

try this example to use JQuery Notification Plugin with ASP.Net

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script>
<script src="http://www.dmitri.me/misc/notify/jquery.notifyBar.js" type="text/javascript"></script>
<link href="http://www.dmitri.me/misc/notify/jquery.notifyBar.css" rel="stylesheet" type="text/css" />
 
<script type="text/javascript">
    function showNotification(message) {
        $.notifyBar({
            html: message,
            delay: 0,
            animationSpeed: "normal"
        });
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Button ID="Submit" runat="server" Text="Submit data" onclick="Submit_Click" />
    </form>
</body>
</html>

and in code behind :-

    protected void Submit_Click(object sender, EventArgs e)
    {
        string message="Thank you, your settings were updated!";
        ClientScript.RegisterStartupScript(Page.GetType(), "key", "showNotification('" + message + "')", true);
    }

Hope this helps

Good Luck

Categories: ASP.Net, Jquery

Change TextBox Color using Required Field Validator

November 1, 2011 Leave a comment

Hi all ,

try this example to Change TextBox Color using Required Field Validator

— Using Client Side :-


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage=""
    ControlToValidate="TextBox1" ClientValidationFunction="ValidateTextBox"
    OnServerValidate="CustomValidator1_ServerValidate"
    ValidateEmptyText="True"></asp:CustomValidator>

<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">
    function ValidateTextBox(source, args)
    {
        var is_valid = $("#TextBox1").val() != "";
        $("#TextBox1").css("background-color", is_valid ? "white" : "red");
        args.IsValid = is_valid;
    }
</script>

— Using Server Side :-

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
    bool is_valid = TextBox1.Text != "";
    TextBox1.BackColor = is_valid ? Color.White : Color.Red;
    args.IsValid = is_valid;
}

Hope this helps

Good Luck

Categories: ASP.Net, Javascript