There are two textbox in which there are dates:
Following c# coding will calculate days between these two date and will display in Label.
DateTime dt1=Convert.toDateTime(TextBox1.text);
DateTime dt2=Convert.toDateTime(TextBox2.text);
TimeSpan ts=dt2.Substract(dt1);
Label1.text=ts.days.toString();
Wednesday, April 7, 2010
Monday, April 5, 2010
Tuesday, March 30, 2010
Order by clause in LINQtosql
Fetch All city order by city name:
dataContext _Data= new dataContext();
var qry = from a in _Data.Cities
orderby a.CName
select a;
dataContext _Data= new dataContext();
var qry = from a in _Data.Cities
orderby a.CName
select a;
Thursday, March 11, 2010
Wednesday, March 10, 2010
ViewState in asp.net
protected void Page_Load(object sender, EventArgs e)
{
ViewState["id"] =Label1.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = (Convert.ToInt32(ViewState["id"])+1).ToString();
ViewState["id"] = Label1.Text;
}
{
ViewState["id"] =Label1.Text;
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = (Convert.ToInt32(ViewState["id"])+1).ToString();
ViewState["id"] = Label1.Text;
}
Logout in Asp.net
protected void Page_Load(object sender, EventArgs e)
{
if (Session["id"] == null)
{
Response.Redirect("Default2.aspx");
}
Label1.Text = Session["id"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session.Abandon();
}
{
if (Session["id"] == null)
{
Response.Redirect("Default2.aspx");
}
Label1.Text = Session["id"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session.Abandon();
}
Disable Copy And Paste In TextBox Control in asp.net
<script language="javascript">
function copy()
{
alert("Can't copy the text");
return false;
}
function paste()
{
alert("can't paste text");
return false;
}
</script>
<asp:TextBox ID="TextBox2" runat="server" Text="hi" oncopy="return copy();" onpaste="return paste();"></asp:TextBox>
function copy()
{
alert("Can't copy the text");
return false;
}
function paste()
{
alert("can't paste text");
return false;
}
</script>
<asp:TextBox ID="TextBox2" runat="server" Text="hi" oncopy="return copy();" onpaste="return paste();"></asp:TextBox>
Subscribe to:
Posts (Atom)
