Tuesday, February 21, 2006

hosts.sam

Today I learnt something new, this is not regarding .NET but networking you can say.
We wanted to test our application by creating many subdomains in the pc, ie; our application needed subdomains for proper testing. Something like http://a.rajesh/dd/index.aspx

Just follow the steps below to achieve this.
Open
C:\WINDOWS\system32\drivers\etc\hosts.sam and in the end added the following

127.0.0.1 localhost
127.0.0.1 a.localhost
127.0.0.1 b.localhost
127.0.0.1 rajesh.rajesh
127.0.0.1 a.rajesh

and saved it.
Then open your browser and type http://a.rajesh/dd/index.aspx and there it goes your localhost will work same as the subdomains... :)

Friday, February 17, 2006

How to open email address in default mail client from a datagrid hyperlink.

How to open email address in default mail client from a datagrid hyperlink?

I was trying this for a long time. How to open the email address (displayed in a datagrid) in the default mail client. If you look at this it will seem very simple.
<asp:HyperLinkColumn DataNavigateUrlField="email" DataNavigateUrlFormatString="mailto:{0}" DataTextField="email" HeaderText="Email"> </asp:HyperLinkColumn>


And here is a link that you will find useful "Common DataGrid Mistakes"
http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/aspnet-commondatagridmistakes.asp

Cheers
Rajesh Sivaraman.

Wednesday, February 15, 2006

Debugging JavaScript using VS.NET 2003

Hi all, earlier I had seen someone debugging JS using VS.NET IDE. And it took a long time for me to find it out. And here it goes...
Before that Long Live "FireFox" and the JavaScript console it provided, without which life would have been miserable.

Now How to Debug JavaScript using VS.NET 2003?
First go to IE (again IE because it is the favourite browser of all)
Tools-->Internet Options-->Advanced and uncheck 'Disable script debugging'.
Now add "debugger" at the place from where you want to start debugging. For Eg;
function change()
{
var img; img = 1;
var path;
debugger alert(img);
path="images\\" + String(img)+ ".gif";
document.Form1.img1.src = path;
//alert(path);
}


Now run the application and there you are debugging the JS....
ps: I have called the js function onload of the body tag.

Some Javascript today....

Vijay wanted a function which will display an image whose number he will pass, for eg if the name of the image is 1.gif he will pass "1" to it.
At first we had trouble of "unterminated string constant" error, later found out that since we had only one slash ("\") in the images (since the image was inside images folder), and javascript has "\" as escape character. So we need to place two "back slashes" and we got it right.
function change()
{
var img;
img = 1;
var path; path="images\\" + String(img)+ ".gif";
document.Form1.img1.src = path;
alert(path);
}
This is a function prototype which I made, parameters need to be added to it.

After making all this and giving Vijay the code, I thought of the great blunder made by me.For the virtual path of the image I was using "\"--> the network slash where as it should be "/". Randeep had told me the same more than once and I am making the same mistake.
So the function will become something like this
function change()
{
var img; img = 1;
var path; path="images/" + String(img)+ ".gif";
document.Form1.img1.src = path;
alert(path);
}

Nice to see that I am repeating the mistakes :-(

Tuesday, February 14, 2006

Got some free time today...

Today I got some free time @ office.. Once in a blue moon day you can say.
So browsed for some .NET stuff and I am adding the links below. Thinking Sometime in future I will need it.

Creating a Class Library (DLL)
http://www.c-sharpcorner.com/2/pr12.asp

New Certifications Microsoft
1. http://www.microsoft.com/learning/mcp/newgen/2. http://www.microsoft.com/learning/mcp/newgen/faq/

Passing values from a page to another by means of the Context objecthttp://www.devx.com/vb2themax/Tip/18847

BuildUrlWithQueryString - Building an Url with a list of parameters in the querystringhttp://www.devx.com/vb2themax/Tip/19481

ShowMessageBox - Showing a client-side message box at the next page loadhttp://www.devx.com/vb2themax/Tip/19678

Manage User Control Values Using Javascript in an .aspx File
http://www.devx.com/tips/Tip/28032

Check All CheckBoxes in an ASP.NET DataGrid Using a Single CheckBox
http://www.devx.com/tips/Tip/20238

How to refer assemblies if different versions are available http://support.softartisans.com/FileUpEEV4/doc/install/install.asp#applevel

Conditional JS validation for IE and Non IE browsers
http://geekswithblogs.net/timh/archive/2006/01/19/66383.aspx


If a key PaymentRequired is "false" or if the key itself is not there then I want to redirect to some page else I want to redirect to another page.

Key in web.conf


In codebehind

If ConfigurationSettings.AppSettings("PaymentRequired") = "false" Then
context.Server.Execute("ByPass.aspx")
Else
Response.Redirect("package_details.aspx", False)
End If

I had used context.server.Execute since the whole code was inside a Try Catch block. If you use Server.Transfer inside a Try-Catch block it will throw exception.

Don't preserve viewstate when doing a Server.Transfer
http://www.devx.com/vb2themax/Tip/18744
http://www.it-pedia.com/