Sunday, April 5, 2009
Saturday, April 4, 2009
Indentation in list item text
While working with dropdownlist control once i was required to dispaly indented text for specific list items, in many of my attempts to achieve this i failed the continueing in search of solution i found this and really a very simple one:
ddl.Add(New ListItem(Server.HtmlDecode("nbsp;nbsp;") & "Maincat1","Maincat1"))
ddl.Add(New ListItem("subcat1-1"))
ddl.Add(New ListItem("subcat1-2"))
ddl.Add(New ListItem(Server.HtmlDecode("nbsp;nbsp;") & "Maincat2","Maincat2"))
ddl.Add(New ListItem("subcat2-1"))
ddl.Add(New ListItem("subcat2-2"))
*ddl is the name dropdownlist on my aspx page.
ddl.Add(New ListItem(Server.HtmlDecode("nbsp;nbsp;") & "Maincat1","Maincat1"))
ddl.Add(New ListItem("subcat1-1"))
ddl.Add(New ListItem("subcat1-2"))
ddl.Add(New ListItem(Server.HtmlDecode("nbsp;nbsp;") & "Maincat2","Maincat2"))
ddl.Add(New ListItem("subcat2-1"))
ddl.Add(New ListItem("subcat2-2"))
*ddl is the name dropdownlist on my aspx page.
Preventing caching of webpage
working on dynamic web pages you may come across a situation where one might start cursing the
web browser back button, because the the obsolete (in that context) page data might become a headache for you.
when i started finding solution to such issue to me java script was the first choice for me, just clearing the browser history using history.go(-1), but for more better approaches i got information about the use of meta tag for that purpose.
the two types are PRAGMA NO-CACHE and cache-control
as all meta tags are required to added in header
i.e
<html>
<head>
meta tags here!
</head>
</html>
try this :
<meta equiv="PRAGMA" content="NO-CACHE">
or
use with:
<meta equiv="PRAGMA" content="NO-CACHE">
<meta equiv="Expires" content="-1">
if doesn't work try the cache control tag
<meta equiv="CACHE-CONTROL" content="NO-CACHE">
if things don't come your way this will surely work for asp.net pages:
Resources:
http://support.microsoft.com/kb/222064
Caching Tutorial
ASP.Net forum post
web browser back button, because the the obsolete (in that context) page data might become a headache for you.
when i started finding solution to such issue to me java script was the first choice for me, just clearing the browser history using history.go(-1), but for more better approaches i got information about the use of meta tag for that purpose.
the two types are PRAGMA NO-CACHE and cache-control
as all meta tags are required to added in header
i.e
<html>
<head>
meta tags here!
</head>
</html>
try this :
<meta equiv="PRAGMA" content="NO-CACHE">
or
use with:
<meta equiv="PRAGMA" content="NO-CACHE">
<meta equiv="Expires" content="-1">
if doesn't work try the cache control tag
<meta equiv="CACHE-CONTROL" content="NO-CACHE">
if things don't come your way this will surely work for asp.net pages:
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetNoStore()
Resources:
http://support.microsoft.com/kb/222064
Caching Tutorial
ASP.Net forum post
Tuesday, February 24, 2009
Search Analytics: Diagnosing what ails your site
Check out this SlideShare Presentation:
Monday, November 3, 2008
Google checkout Fast Track
I am currently working on an e-commerce website, as shopping cart is one of the most important part of such websites. There are different options available for receiving and processiong orders one them is service provided by google as "Google Checkout"
A quick Start
As most of the services there is a special development environment for the developers known as "Sandbox" u can rfere for a Proper introduction.
let me summarize things in steps:
Once The Accounts are set its time to move ahead:
these are the basic requirement .
Basic Html Test:
https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/1234567890
by
https://sandbox.google.com/checkout/cws/v2/Merchant/[[Merchant-ID]]/checkoutform
and
http://checkout.google.com/buttons/checkout.gif?merchant_id=123456789
by
http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=[[Merchant-ID]]
Then just click the button in the html file , it should take you to the Sanndbox checkout,
where you should login with your "Sandbox Buyer Account" . you have purchased a peanut butter.
If this test is successful now is the time to move onward.
Integrating The Google Checkout Using Xml Api on .Net Platform.
To do this quickly you need to find some library files i mean(DLLs) so you can make your life easier that what developers try to do, as i did i am thankful to the author of this libraray.
i want to thank All :
martin.omander, chanezon, joseph.feser, moman...@google.com
as this helped me alot this can be accessed at
http://code.google.com/p/google-checkout-dotnet-sample-code/
you can download GCheckout ,
it is very much useful to review the documentation before using this here
you will have to do some configuration and set the environment, then by referencing
the library create request and post you cart items via google checkout.
i hope this post may help you for quick start.
A quick Start
As most of the services there is a special development environment for the developers known as "Sandbox" u can rfere for a Proper introduction.
let me summarize things in steps:
- Create sandbox merchant Account(the seller) : http://sandbox.google.com/checkout/sell/.
- Create sandbox Buyer Account:http://sandbox.google.com/checkout
Once The Accounts are set its time to move ahead:
- log in to your Sandbox Merchant Account here .
- get your sandbox merchant Id and key
| Google merchant ID: xxxxxxxxxxxxxxxxxx |
| Google merchant key: xxxxxxxxxxxxxxxxxx |
Basic Html Test:
- To do this get the html code and save a new html file here .
https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/1234567890
by
https://sandbox.google.com/checkout/cws/v2/Merchant/[[Merchant-ID]]/checkoutform
and
http://checkout.google.com/buttons/checkout.gif?merchant_id=123456789
by
http://sandbox.google.com/checkout/buttons/checkout.gif?merchant_id=[[Merchant-ID]]
Then just click the button in the html file , it should take you to the Sanndbox checkout,
where you should login with your "Sandbox Buyer Account" . you have purchased a peanut butter.
If this test is successful now is the time to move onward.
Integrating The Google Checkout Using Xml Api on .Net Platform.
To do this quickly you need to find some library files i mean(DLLs) so you can make your life easier that what developers try to do, as i did i am thankful to the author of this libraray.
i want to thank All :
martin.omander, chanezon, joseph.feser, moman...@google.com
as this helped me alot this can be accessed at
http://code.google.com/p/google-checkout-dotnet-sample-code/
you can download GCheckout ,
it is very much useful to review the documentation before using this here
you will have to do some configuration and set the environment, then by referencing
the library create request and post you cart items via google checkout.
i hope this post may help you for quick start.
Sunday, July 13, 2008
HTTP Handlers in .Net
Introduction :
In simple words what i understand is that as the name suggests "they are meant to process the http Request by the client and generate the response. "
They are uesd by ASP.Net to handle requests for the .aspx pages.
Why and Where to use:
use of HTTP Handler(your custom) can be a alternative and better approach than .aspx page
depending on the scenario
for example :
application to application Interaction ( data posted by using XML Http from one form to other and receiving response)
Dim requestXML As New StringBuilder()
Dim oXMLHttp As New XMLHTTP
requestXML.Append("")
requestXML.Append("Rate ")
requestXML.Append("Shop ")
Dim Domain As String = HttpContext.Current.Request.ServerVariables("Server_Name") + ":" + HttpContext.Current.Request.ServerVariables("Server_Port")
oXMLHttp.open("POST", "http://" + Domain + "/httphandling/Default.aspx", False)
oXMLHttp.setRequestHeader("Content-Length", (requestXML.ToString.Length))
oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
oXMLHttp.send(requestXML.ToString)
Dim response As String = oXMLHttp.responseText
In the above code a xml string is sent to the "Default.aspx" where it is processed and Response is sent back.
So, what is the role of Default.aspx more specifically no visual content.
this is the case where there is Over head of Processing of the .Aspx page life cycle
So, Http Handler Can be used to overcome this Issue.
How to use:
There are Two Approaches Available to my knowledge.
The one require more effort the other bit easier.
First Approach :
Implementing The System.Web.IHttpHandler Details
I personally Found The Following Article Very Helpful Thanks to the author
Implementing HttpHandelers
Now Let us come The :
Second Approach:
Using The .ashx "web Handler" the template is available in Visual studio.Net
you donot require registring the file extension in web.Config
for details : visit
Now using This approach:
on The page sending Request:
Dim requestXML As New StringBuilder()
Dim oXMLHttp As New XMLHTTP
requestXML.Append("")
requestXML.Append("Rate ")
requestXML.Append("Shop ")
Dim Domain As String = HttpContext.Current.Request.ServerVariables("Server_Name") + ":" + HttpContext.Current.Request.ServerVariables("Server_Port")
oXMLHttp.open("POST", "http://" + Domain + "/httphandling/Handler.ashx", False)
oXMLHttp.setRequestHeader("Content-Length", (requestXML.ToString.Length))
oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
oXMLHttp.send(requestXML.ToString)
Dim response As String = oXMLHttp.responseText
On The Handler.ashx
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using System.IO;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
StreamReader rd = new StreamReader(context.Request.InputStream);
string str=rd.ReadToEnd();
//processing of the request string
context.Response.Write("Yes, I received you request");
}
public bool IsReusable {
get {
return false;
}
}
}
I hope this might be helpful to the readers
In simple words what i understand is that as the name suggests "they are meant to process the http Request by the client and generate the response. "
They are uesd by ASP.Net to handle requests for the .aspx pages.
Why and Where to use:
use of HTTP Handler(your custom) can be a alternative and better approach than .aspx page
depending on the scenario
for example :
application to application Interaction ( data posted by using XML Http from one form to other and receiving response)
Dim requestXML As New StringBuilder()
Dim oXMLHttp As New XMLHTTP
requestXML.Append("")
requestXML.Append("
requestXML.Append("
Dim Domain As String = HttpContext.Current.Request.ServerVariables("Server_Name") + ":" + HttpContext.Current.Request.ServerVariables("Server_Port")
oXMLHttp.open("POST", "http://" + Domain + "/httphandling/Default.aspx", False)
oXMLHttp.setRequestHeader("Content-Length", (requestXML.ToString.Length))
oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
oXMLHttp.send(requestXML.ToString)
Dim response As String = oXMLHttp.responseText
In the above code a xml string is sent to the "Default.aspx" where it is processed and Response is sent back.
So, what is the role of Default.aspx more specifically no visual content.
this is the case where there is Over head of Processing of the .Aspx page life cycle
So, Http Handler Can be used to overcome this Issue.
How to use:
There are Two Approaches Available to my knowledge.
The one require more effort the other bit easier.
First Approach :
Implementing The System.Web.IHttpHandler Details
I personally Found The Following Article Very Helpful Thanks to the author
Implementing HttpHandelers
Now Let us come The :
Second Approach:
Using The .ashx "web Handler" the template is available in Visual studio.Net
you donot require registring the file extension in web.Config
for details : visit
Now using This approach:
on The page sending Request:
Dim requestXML As New StringBuilder()
Dim oXMLHttp As New XMLHTTP
requestXML.Append("")
requestXML.Append("
requestXML.Append("
Dim Domain As String = HttpContext.Current.Request.ServerVariables("Server_Name") + ":" + HttpContext.Current.Request.ServerVariables("Server_Port")
oXMLHttp.open("POST", "http://" + Domain + "/httphandling/Handler.ashx", False)
oXMLHttp.setRequestHeader("Content-Length", (requestXML.ToString.Length))
oXMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
oXMLHttp.send(requestXML.ToString)
Dim response As String = oXMLHttp.responseText
On The Handler.ashx
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using System.IO;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
StreamReader rd = new StreamReader(context.Request.InputStream);
string str=rd.ReadToEnd();
//processing of the request string
context.Response.Write("Yes, I received you request");
}
public bool IsReusable {
get {
return false;
}
}
}
I hope this might be helpful to the readers
Subscribe to:
Posts (Atom)
