Last week i answered a question in forums.asp.net ( http://forums.asp.net/t/1877542.aspx/1?Webform+progress+Bar+ ) His criteria is in his words
In this blog i'm posting some Asp.net,Sql Server,Jquery,HTML-5,sqlite,C#,JavaScript scripts and sample codes that i found and created by me or my friends with a mind that it Save/ Help our ass some ways...
Thursday, January 31, 2013
Wednesday, January 30, 2013
Remove Duplicate Row from datatable in c#
As i was also unaware of this feature until i read as answer in fourms.asp.net (link). Previously i was achieved by using lambda expression.Now no need to those just one line code :)
If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)
DataTable dt = new
DataTable
{
Columns ={
{"Myid",typeof(int)},
{"Name"},
{"Address"}
}
};
dt.Rows.Add(1, "Arun Aravind",
"Kollam");
dt.Rows.Add(1, "Arun Aravind",
"Kollam");
dt.Rows.Add(2, "Arun Aravind",
"Kollam");
dt.Rows.Add(2, "Arun Aravind",
"Kollam");
dt.Rows.Add(3, "Arun Aravind",
"Kollam");
dt =
dt.DefaultView.ToTable(false, "Address", "Name",
"Myid");
Output
If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)
Tuesday, January 29, 2013
Changing image within Gridview programatically
Simple RowdataBound event isit? an alternate if it reduce memory load and time. wht abt that :)
Yup by jquery :)
Yup by jquery :)
Monday, January 28, 2013
Reflection in c#
After a series of post regarding caches, we are into reflection now.
Here i'm posting how to invoke a method,Getting events properties,fields from a class using reflection.
For that i created a console application ( named : ReflectionConsoleApplication ) and invoke using System.Reflection; Namespace and created a class and code goes below.
Here i'm posting how to invoke a method,Getting events properties,fields from a class using reflection.
For that i created a console application ( named : ReflectionConsoleApplication ) and invoke using System.Reflection; Namespace and created a class and code goes below.
Labels:
Asp.net,
C#,
Oop,
server side
Sunday, January 27, 2013
Exploring more in cache in asp.net-- remove cache-- part 5
I covered a few topic about cache in asp.net except one how to remove a cache :)
HttpContext.Current.Cache.Remove("customers"); // customers my cache name
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
HttpContext.Current.Cache.Remove("customers"); // customers my cache name
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
Saturday, January 26, 2013
Exploring more into caching in asp.net-- Data Caching (Part 4)
ASP.NET also supports caching of data as objects. We can store objects in memory and use them across various pages in our application. This feature is implemented using the Cache class. This cache has a lifetime equivalent to that of the application. Objects can be stored as name value pairs in the cache. A string value can be inserted into the cache as follows:
Cache["name"]
= "Arun Aravind";
if (Cache["name"]
!= null)
Label1.Text = Cache["name"].ToString();
To insert objects into the cache, the Add method or different versions of the Insert method of the Cache class can be used. These methods allow us to use the more powerful features provided by the Cache class.
protected void Page_Load(object sender, EventArgs
e)
{
ArrayList datestamps;
if (Cache["datestamps"]
== null)
{
datestamps = new ArrayList();
datestamps.Add(DateTime.Now);
datestamps.Add(DateTime.Now);
datestamps.Add(DateTime.Now);
Cache.Add("datestamps",
datestamps, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 0,
60), System.Web.Caching.CacheItemPriority.Default,
null);
}
else
datestamps = (ArrayList)Cache["datestamps"];
foreach (DateTime
dt in datestamps)
Response.Write(dt.ToString() + "<br
/>");
}
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
Friday, January 25, 2013
Exploring more into caching in asp.net-- Caching page fragments (Part 3)
Sometimes we might want to cache just portions of a page. For example, we might have a header for our page which will have the same content for all users. There might be some text/image in the header which might change everyday. In that case, we will want to cache this header for a duration of a day.
The solution is to put the header contents into a user control and then specify that the user control content should be cached. This technique is called fragment caching.
To specify that a user control should be cached, we use the @OutputCache directive just like we used it for the page.
With the above directive, the user control content will be cached for the time specified by the Duration attribute [10 secs]. Regardless of the querystring parameters and browser type and/or version, the same cached output is served.
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
The solution is to put the header contents into a user control and then specify that the user control content should be cached. This technique is called fragment caching.
To specify that a user control should be cached, we use the @OutputCache directive just like we used it for the page.
<%@ OutputCache
Duration=10 VaryByParam="None"
%>
With the above directive, the user control content will be cached for the time specified by the Duration attribute [10 secs]. Regardless of the querystring parameters and browser type and/or version, the same cached output is served.
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
Thursday, January 24, 2013
Exploring more into caching in asp.net (Part 2)
In order to cache a page's output, we need to specify an @OutputCache directive at the top of the page. The syntax is as shown below:
<%@ OutputCache
Duration=5 VaryByParam="None"
%>
Wednesday, January 23, 2013
I started loving Cache :) Part 1
Hi *.*,
When it comes to build a high-performance and scalable ASP.Net Web applications Caching is inevitable. It has the ability to store objects whether its data object or pages or controls or even parts of a page. The plan is to keep them in memory while initially requested. You can store them in web-server or in proxy-server or in browser, your choice. Using this feature prevents you recreating information while it already satisfied in previous request. The motive is reusing the objects when they are needed.
Basically ASP.Net provides two types of caching. Output caching and another one is traditional application data caching. There are few good practices to cache your data. When the data is going to be used more than once it’s a candidate for caching and if data is general rather than specific to a given request or user, it’s a great candidate for the cache. But the thing sometimes developers often overlook is that they can cache too much and it causes out of memory exception. Therefore, caching should be bounded. In my experience ASP.NET out-of-memory errors caused by overcaching, especially of large datasets.
So how do you use this? – If your components are running within an ASP.NET application, you simply need to include a reference to System.Web.dll in your application project. When you need access to the Cache, use the HttpRuntime.Cache property (the same object is also accessible through Page.Cache and HttpContext.Cache).
By default Location property sets to "Any" which means this stores the output cache in the client’s browser, on the proxy server (or any other server) that participates in the request, or on the server where the request is processed.
The choices you have are "Server", "Client", "Downstream" or "None".
And the programmatic approach for Output cache is
Here is an example. Suppose your target is to fill a DataGrid, if the DataSet is already been stored you’ll ignore re-filling it, otherwise you’ll fill the DataSet and will cache it.
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
When it comes to build a high-performance and scalable ASP.Net Web applications Caching is inevitable. It has the ability to store objects whether its data object or pages or controls or even parts of a page. The plan is to keep them in memory while initially requested. You can store them in web-server or in proxy-server or in browser, your choice. Using this feature prevents you recreating information while it already satisfied in previous request. The motive is reusing the objects when they are needed.
Basically ASP.Net provides two types of caching. Output caching and another one is traditional application data caching. There are few good practices to cache your data. When the data is going to be used more than once it’s a candidate for caching and if data is general rather than specific to a given request or user, it’s a great candidate for the cache. But the thing sometimes developers often overlook is that they can cache too much and it causes out of memory exception. Therefore, caching should be bounded. In my experience ASP.NET out-of-memory errors caused by overcaching, especially of large datasets.
So how do you use this? – If your components are running within an ASP.NET application, you simply need to include a reference to System.Web.dll in your application project. When you need access to the Cache, use the HttpRuntime.Cache property (the same object is also accessible through Page.Cache and HttpContext.Cache).
By default Location property sets to "Any" which means this stores the output cache in the client’s browser, on the proxy server (or any other server) that participates in the request, or on the server where the request is processed.
The choices you have are "Server", "Client", "Downstream" or "None".
And the programmatic approach for Output cache is
TimeSpan freshness = new TimeSpan(0,0,0,60); DateTime now = DateTime.Now; Response.Cache.SetExpires(now.Add(freshness)); Response.Cache.SetMaxAge(freshness); Response.Cache.SetCacheability(HttpCacheability.Server); Response.Cache.SetValidUntilExpires(true);
Here is an example. Suppose your target is to fill a DataGrid, if the DataSet is already been stored you’ll ignore re-filling it, otherwise you’ll fill the DataSet and will cache it.
DataView Source;
// Retrieve the DataView object from Cache. If not exist,
then add DataView object to the Cache.
Source = (DataView)Cache["MyDataSet"];
if (Source == null)
{
SqlConnection myConnection = new
SqlConnection("Server=ServerName;
database=Pubs; user id=UID; password=PWD;");
SqlDataAdapter myCommand = new
SqlDataAdapter("select * from Authors",
myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "Authors");
Source = new DataView(ds.Tables["Authors"]);
Cache["MyDataSet"] =
Source;
CacheMsg.Text = "Dataset created
explicitly";
}
else
{
CacheMsg.Text = "Dataset retrieved from
cache";
}
// Binding the DataView object with DataGrid.
DataGrid1.DataSource = Source;
DataGrid1.DataBind();
Now u got y i titled this post so...
If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)
Tuesday, January 22, 2013
Convert a datatable to Json c#
Hi *.*,
I'm so happy today to introduce this.Last day by noon i got a crazy idea to create own json converter. i don't have a plan or an architecture how it goes, where to start. all what i had is a json string :). I finished that by 2 hr 50 min. :)
For the reusability of the code i created that by extension method. and i named the class JsonExtensionMethod class goes below.
I'm so happy today to introduce this.Last day by noon i got a crazy idea to create own json converter. i don't have a plan or an architecture how it goes, where to start. all what i had is a json string :). I finished that by 2 hr 50 min. :)
For the reusability of the code i created that by extension method. and i named the class JsonExtensionMethod class goes below.
public static class JsonExtensionMethod
{
Monday, January 21, 2013
Invoking an Event in ASPX Page from UserControl
UserControl
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
Sunday, January 20, 2013
Enable and Disable Regular field validation using javascript
Enable and Disable Regular field validation using javascript
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.9.0.min.js"
type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt01" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
ControlToValidate="txt01"
CssClass="val"
EnableClientScript="true"
runat="server"
ErrorMessage="errro"></asp:RequiredFieldValidator>
<asp:Button ID="btnEnable"
CssClass="enb"
runat="server"
Text="Enable
validation" />
<asp:Button ID="btnDisable"
runat="server"
CssClass="Dis"
Text="Disable
Validation" />
Subscribe to:
Posts (Atom)