Get C#, ASP.NET, HTML, JavaScript, XML, WCF, Web services and Ajax tips.
menu
- Home
- Asp.Net
- MVC
-
C#
- Ref
- Constructor
- Constructor Program
- Jagged Array
- Command Line Argument
- Stack and Heap
- Ref and Out
- Const, ReadOnly and Static
- Generic
- Two Interfaces With Same Method Name
- Inheritance
- Is Keyword
- Custom List with OnAdd Event
- Data Annotation
- Covariance & Contravariance
- Signing - Strong vs Weak Reference
- Sorting List by IComparable vs IComparer
- WCF
- JavaScript
- SQL
- Others
- Contact
Thursday, August 16, 2012
Command Line Argument in C Sharp
Jagged Array
Constructor in C Sharp
|
public class A
{
public
A()
{
Console.WriteLine("A");
}
}
public class B:A
{
public
B()
{
Console.WriteLine("B");
}
}
class Program
{
static void Main(string[]
args)
{
B
objB = new B();
Console.WriteLine("C");
Console.ReadKey();
}
}
|
public class
A
{
static
A() // this static constructor will called only once
{
Console.WriteLine("A");
}
public
A(int x)
{
Console.WriteLine("A1");
}
}
public class B : A
{
public
B():base(1)
{
Console.WriteLine("B");
}
}
class Program
{
static
void Main(string[]
args)
{
B
objB = new B();
Console.WriteLine("C");
Console.ReadKey();
}
}
|
|
public class B
{
private
B()
{
Console.WriteLine("B");
}
}
class Program
{
static
void Main(string[]
args)
{
B
objB = new B();
Console.WriteLine("C");
Console.ReadKey();
}
}
|
public class B
{
public
static B()
{
Console.WriteLine("B");
}
}
class Program
{
static
void Main(string[]
args)
{
B
objB = new B();
Console.WriteLine("C");
Console.ReadKey();
}
}
|
Thursday, July 7, 2011
Check All Check box in Grid View Control without Postback
<script type="text/javascript" language="javascript">
function checkAllBoxes(grid, num)
{
var totalChkBoxes = parseInt(num);
var gvControl = document.getElementById(grid);
var gvChkBoxControl = "chkBoxChild";
var mainChkBox = document.getElementById("chkBoxAll");
var inputTypes = gvControl.getElementsByTagName("input");
for(var i = 0; i < inputTypes.length; i++)
{
if(inputTypes[i].type == 'checkbox' && inputTypes[i].id.indexOf(gvChkBoxControl,0) >= 0)
inputTypes[i].checked = mainChkBox.checked;
}
}
</script>
<asp:GridView ID="grdDR" runat="server">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id="chkBoxAll" type="checkbox"
onclick="checkAllBoxes('<%= grdDR.ClientID %>', '<%= grdDR.Rows.Count %>')" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkBoxChild" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Trns ID" HeaderText="Trns ID" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="User" HeaderText="User" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="Deposit Amount" HeaderText="Deposit Amount" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
Monday, May 23, 2011
Row Number in GridView

Grid View Row Color on RewDataBound Event

Grid View:
Repeater Row Color on ItemDataBound Event
protected void rep_ServiceStatus_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
foreach (Control c in e.Item.Controls)
{
if (c is System.Web.UI.HtmlControls.HtmlTableRow)
{
HtmlTableRow tr = (HtmlTableRow)c;
foreach (Control c1 in tr.Controls)
{
LinkButton myLink = (LinkButton)c1.FindControl("lnk_ChangeStatus");
if (myLink.CommandArgument.ToString() == "Active")
{
tr.BgColor = "#99FFCC";
}
else if (myLink.CommandArgument.ToString() == "InActive")
{
tr.BgColor = "#FFCCFF";
}
}
}
}
}
}