Search This Blog

May 20, 2009

How to rename all the file extensions in a folder

Open a command/cmd window
navigate to the folder
type the following command
rename *.originalextension *.newextension
Example: To cange all jpg file extensions to gif extensions. You can use the following command.
rename *.jpg *.gif
Modify the values originalextension and newextension as required.
You can save this command in a batch file and execute in the respective folders.

March 23, 2009

Asp.Net Errors and Resolution

1. Sys.WebForms.PageRequestManagerServerErrorException: Exception has been thrown by the target of an invocation.
When used updatePanel and fileupload controls a client side message displays as above.

To resolve this issue follow the following instructions. orginal link
http://forums.asp.net/p/1100270/2468298.aspx#2468298


<triggers>
<asp:postbacktrigger controlid="fileUpload1">
</triggers>

This works perfect whenever the FileUpload control is a child control of the UpdatePanel's ContentTemplate.However when the FileUpload control is a child control of e.g. a DetailsViews, which is a child control of the UpdatePanel's ContentTemplate, we should not postback the FileUpload control but it's container.
So in this case you would have to postback the DetailsView by using it's ID.

<triggers>
<asp:postbacktrigger controlid="detailsView1" />
</triggers>

January 30, 2009

How to Send email from ASP.NET

In the web.config file add the following configuration

<system.net>
<mailSettings>
<smtp from="yourmailid@domain.com">
<network host="localhost" port="25" />
</smtp>
</mailSettings>
</system.net>

In the ASP.NET code

try
{
System.Net.Mail.SmtpClient Client = new System.Net.Mail.SmtpClient();
Client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.PickupDirectoryFromIis;
Client.Send("Frommailid@domin.com", "tomailid@domain.com", "Mail Sumbjet", "Mail Body");
}
catch (Exception ex)
{
Response.Wrire(ex.Message.ToString());
}