Archive

Archive for March, 2016

IIS 7 Blank Image Problem

March 15, 2016 Leave a comment

Hi all,

Try this to solve IIS 7 Blank Images Problem

static content

Hope this helps

Good Luck

Categories: ASP.Net

Removing Empty Spaces and HTML tags from TextBox text on Client Side

March 6, 2016 Leave a comment

Hi all,

Try this example for Removing Empty Spaces and HTML tags from TextBox text on Client Side

To remove spaces from textbox’s text in onblur event :

<asp:TextBox ID="TextBox2" runat="server" onblur="javascript:value=value.replace(/\s/g,'');"></asp:TextBox>

To remove HTML tags :

<asp:textbox id="TextBox2" runat="server" onblur="this.value = this.value.replace(/<\/?[^>]+>/gi, '');"></asp:textbox>

Hope this helps

Good Luck.

Categories: Uncategorized

GridView with Fixed Header and Scroll Bar

March 5, 2016 Leave a comment

Hi all,

try this example to create GridView with Fixed Header and Scroll Bar


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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Fixed Header GridView</title>
<style type="text/css">
.FixedHeader {
position: absolute;
font-weight: bold;
vertical-align:text-bottom;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h2 align="center">GridView with Fixed Header</h2>
<div style="height: 400px; overflow: auto" align="center">
<asp:GridView ID="gvDistricts" runat="server" HeaderStyle-CssClass="FixedHeader" HeaderStyle-BackColor="YellowGreen"
AutoGenerateColumns="false" AlternatingRowStyle-BackColor="WhiteSmoke" OnRowDataBound="gvDistricts_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="District ID" HeaderStyle-Width="80px" ItemStyle-Width="80px">
<ItemTemplate>
<asp:Label ID="lblDistID" runat="server" Text='<%#Eval("DistID")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="District Name" HeaderStyle-Width="120px" ItemStyle-Width="120px">
<ItemTemplate>
<asp:Label ID="lblDistName" runat="server" Text='<%#Eval("DistName")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<Columns>
<asp:TemplateField HeaderText="Description" HeaderStyle-Width="200px" ItemStyle-Width="200px">
<ItemTemplate>
<asp:Label ID="lblDistDesc" runat="server" Text='<%#Eval("DistDesc")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>

In Code behind :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ConStr = "Data Source=.\\sqlexpress;Initial Catalog=MYDB;Integrated Security=True";
if (!IsPostBack)
{
string Query = "SELECT * FROM Districts";
SqlConnection con = new SqlConnection(ConStr);
SqlDataAdapter adp = new SqlDataAdapter(Query, con);
DataTable dt = new DataTable();
adp.Fill(dt);
gvDistricts.DataSource = dt.DefaultView;
gvDistricts.DataBind();
}
}

protected void gvDistricts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex == 0)
e.Row.Style.Add("height", "50px");
}
}
}

Hope this helps

Good Luck

Categories: Uncategorized