Sunday, February 27, 2011

How to disable cacheing on page

To Prevent caching of web pages by browsers


The web pages you view are stored by your system inside the cache directory. Now, when you view these pages again, the browser searches the cache, and if it finds the page there, it displays it immediately. This presents problems to web developers when they update a page since the visitors see an older version (that was stored in the cache) of the page.

To prevent this from happening set the expiration date in the past inside the <meta>. Thus the browser reloads the page everytime the user visits.

Use below code

<meta http-equiv="expires" value="Thu, 16 Mar 2000
11:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

Another way to do this is by writing asp.net code:

Add the following line on top of the Page_Load event handler and your ASP.NET page will not be cached in the users browsers:

Response.Cache.SetCacheability(HttpCacheability.NoCache)

Solution by: Rajesh Rolen

Read More

Wednesday, February 16, 2011

How to Replace All Occurrences of a String using Javascript Replace Function

As we all use javascript's "replace()" function to replace string but normally it replace only first matched text and leave all other.
for eg.
var string_variable = "this is stringToBeReplaced and now again stringToBeReplaced occurred";
string_variable = string_variable.replace("stringToBeReplaced", "NewString");
now if you will print value of string_variable then it will be like:
"this is NewString and now again stringToBeReplaced occurred"
so as you can see in above string only first concurrence of "stringToBeReplaced" is replaced.

Now, if you wants to replace all occurrence of string then the same "replace()" function can help you out:

eg.
var string_variable = "this is stringToBeReplaced and now again stringToBeReplaced occurred";
string_variable = string_variable.replace(/stringToBeReplaced/g, "NewString");
now if you will print value of string_variable then it will be like:
"this is NewString and now again NewString occurred"
How we can enable global regular expression is as simple as adding the "g" identifier following the regular expression.
Using "g" following the regular expression pattern, builtin javascript replace method will replace all matches and all occurences of the given text variable with the new string.

Solution By: Rajesh Rolen

Read More

Monday, February 14, 2011

Generic Functions

In general Generic function provide us facility to


1. create such a function whose return type we can decide while making call to that function.

Eg.
let say i wants to create a function which takes a string and return me that value to be converted in any other type. like i pass any string value and i wants it to be returned as a int/date/any other type.

public T GetValue(string value)
  {
     return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
  }
call it like:
int x = GetValue("1234");
in above call we are setting that we wants the result of "GetValue" function as a "int" so i called it like "GetValue".


2. we can create such function whose parameter's datatype can be decide while making call to that function.

eg. i wants to create a function which can be used to swap values of two variables and the variables can be of any datatype means i can pass int/float/string/date.
so to do earlier we was to create lots of overloaded function. means 1 function for each supported datatype.
but we can do it easily just by writing a single function as a generic function.
static void Swap(ref T lhs, ref T rhs)
{
    T temp;
    temp = lhs;
    lhs = rhs;
    rhs = temp;
}
you can call it like:
Swap(ref a, ref b);
even it provides you more flexibility like you can also omit the type argument and the compiler will infer it. The following call to Swap is equivalent to the previous call:
Swap(ref a, ref b);


Definition:Generic functions are functions declared with a generic type parameter. They may be methods in a class or struct, or standalone functions. A single generic declaration implicitly declares a family of functions that differ only in the substitution of a different actual type for the generic type parameter.

When called, the generic type parameter is replaced by an actual type. The actual type may be explicitly specified in angled brackets using syntax similar to a template function call. If called without the type parameters, the compiler will attempt to deduce the actual type from the parameters supplied in the function call. If the intended type argument cannot be deduced from the parameters used, the compiler will report an error.

References: http://msdn.microsoft.com/en-us/library/ssea4yk6%28v=vs.80%29.aspx

Solution By: Rajesh Rolen

Read More

Deny User to use "Select *" on SQL Table

As we all knows that if we use "Select *" in any query it reduce performance and its not a good practice. this is not best practice to use "select *". user/developer must pass field's name instead of using "*".
as normally every developer takes care about it but even though there is possibility to use it in queries.
so if you wants that no query with "select *" should work then you can do it using just single statement.

add a column to table on which you don't want "select *" to be run.
like:
alter table tablename add column 
 DummyColumn CHAR(1) NULL

now deny rights to run "select" our newly added column named "dummycolumn" for user.

DENY SELECT ON OBJECT:: dbo.yourTableName(DummyColumn) TO your_user;

now if you will try to run
Select * from tableName
you will encounter this error:
The SELECT permission was denied on the column 'DummyColumn' of the object 'YourTableName", database 'YourDatabaseName', schema 'dbo'.

The only way to use this table is by passing column names with select like
select firstcolumnName, secondecolumnName from yourTableName

There are a few things that this user cannot do such as: COUNT(*), COUNT(1) or even SELECT 1 from this table. But there is a way around it. Replacing the * or 1 with the primary key on that table gives the desired results.

I agree it seems too much work to make sure that the users don't use SELECT *, but if you really want to enforce it, here's one way to go about it. But if you know better then please suggest me..

Solution By: Rajesh Rolen.

Read More

What is Cloud Computing

Defination:
1. Cloud computing describes computation, software, data access, and storage services that do not require end-user knowledge of the physical location and configuration of the system that delivers the services. Parallels to this concept can be drawn with the electricity grid where end-users consume power resources without full understanding of every component device in the grid required to provide said service.

2. Cloud computing is an emerging computing technology that uses the internet
and central remote servers to maintain data and applications.

INTRODUCTION

The underlying concept of cloud computing dates back to 1960, when
John McCarthy opined that "computation may someday be organized
as a public utility"; indeed it shares characteristics with service bureaus
that date back to the 1960s.

The actual term "cloud" borrows from telephony in that
telecommunications companies, who until the 1990s primarily offered
dedicated point-to-point data circuits, began offering ³VIRTUAL
PRIVATE NETWORK (VPN)´ services with comparable quality of
service but at a much lower cost.

The cloud symbol was used to denote the demarcation point between
that which was the responsibility of the provider from that of the user.
Cloud computing extends this boundary to cover servers as well as the
network infrastructure.

Cost is claimed to be greatly reduced and capital expenditure is
converted to operational expenditure. Device and location
independence enable users to access systems using a web browser
regardless of their location or what device they are using.

USES

Helps to use applications without installations.

Access the personal files at any computer with
internet access.


This technology allows much more efficient
computation by centralizing storage, memory,
processing and band width.
Read More

Sunday, February 13, 2011

Windows Azure Training

Read More

Windows Azure Free Training Videos

Now a days every body is looking for taking knowledge about cloud and specially for windows Azure. Here are the contents of this 12-hour free windows azure video series which can be viewed online or downloaded.

Session 01: Windows Azure Overview - This session provides an engaging overview of why the Cloud is such a popular choice for applications, and how the Windows Azure Platform is the best alternative for you and your team.

Session 02: Introduction to Compute - This session deals with options for sensitive data, considerations from a legal and regulatory perspective, and the availability of Cloud resources.

Session 03: Windows Azure Lifecycle, Part 1 - This is Part 1 of a two-part section and covers the following components of the Application Life Cycle: Design, Development, and Deployment.

Session 04: Windows Azure Lifecycle, Part 2 - This is Part 2 of a two-part section and covers the following components of the Application Life Cycle: Testing, Management, Scale and Upgrade.

Session 05: Windows Azure Storage, Part 1 - This is Part 1 of a two-part section and covers the following options for storage as well as ways to access storage when leveraging the Windows Azure Platform: Non-Relational Storage, Relational SQL Azure Storage, Blobs, Drives, RESTful web services, and Content Delivery Networks (CDN).

Session 06: Windows Azure Storage, Part 2 - This is Part 2 of a two-part section and covers the following options for storage as well as ways to access storage when leveraging the Windows Azure Platform: Queues, Tables, RESTful web services.

Session 07: Introduction to SQL Azure – This session provides an introduction to SQL Azure, including Motivation, Architecture, Working with SQL Azure and Sync.

Session 08: Windows Azure Diagnostics - This session walks users through how to perform diagnostics in the Cloud. It covers the Diagnostics Monitor, ways to collect diagnostics data, persisting data in Windows Azure Storage and common usage scenarios.

Session 09: Windows Azure Security, Part 1 - This is Part 1 of a two-part section and walks users through options for Security in the Cloud. It covers the advantages and disadvantages of Role base Identity vs. Claim based Identity and Windows Identity Framework (WIF).

Session 10: Windows Azure Security, Part 2 - This is Part 2 of a two-part section and walks users through options for Security in the Cloud. It covers Access Control Service (ACS) and Shared Access Signatures.

Session 11: Scalability, Caching & Elasticity, Part 1 - This is Part 1 of a two-part section and helps learners understand how to ensure appropriate scalability, caching and elasticity into their applications using the Windows Azure Platform. Achieving linear scale, scaling up vs. scaling out, and choosing VM sizes are covered.

Session 12: Scalability, Caching & Elasticity, Part 2, and Q&A , and Q&A - This is Part 2 of a two-part section and also includes some Q&A discussion covering various aspects of content from the entire course. Approaches to caching and cache storage, as well as the automation of scaling are among the topics covered

Solution By: Rajesh Rolen
Read More

Wednesday, February 9, 2011

How to add meta tags programmatically

to

add meta tags programmatically

you will have to create object of htmlmeta and set values in it and then add it to page's header.
below code will help you in creating meta tags programmatically.

  private void createMetaTags(string content)
    {
        HtmlMeta hm = new HtmlMeta();
        HtmlHead head = (HtmlHead)Page.Header;
        hm.Name = "Keywords";
        hm.Content = content;
        head.Controls.Add(hm);
       
    }

Solution By: Rajesh Rolen
Read More
Powered By Blogger · Designed By Seo Blogger Templates