Showing posts with label meetuchoudhary. Show all posts
Showing posts with label meetuchoudhary. Show all posts

Sunday, August 16, 2009

Isolated Storage in the Silverlight Application

Isolated Storage

Isolated Storage in the Silverlight Application

Definition:
Isolated storage is a mechanism which, provide data storage isolation and safety by defining standardized ways of associating code with saved data. Standardization provides some more benefits as well.
Uses of tools from designing, reconfiguration storage, make security
policies apart from this remove unused data all are the tasks of
Administrators

Using isolated storage there no need to write unique paths in the file system, so, hard-coded things are immaterial. With this all is controlled by computer's security policy. The uses of this is appreciable in web applications where user/client must have to use some cautions while running these applications.
Security policy doe not allow to access the file system using I/O mechanism, by default all is granted to access isolated storage

For more information on Isolated Storage Visit here

How to increase the space of the issolatedStorage of the application


Steps To Test The Current Space for the application

  1. Run any Silverlight Application Right click on it it will show you the silverlight button. Click on it

  2. Now the Silverlight properties Dialog will appear
    Now select the Application Storage Tab It will show you the Application storgae for all the silverlight application on the system

    Meetu
    Steps

  3. Create an application with the name "IsolatedStorageApp". You can name it as per your choice I will be using this in my example Application.
    Meetu

    Add New silverlight control and name it as "IncreaseIsolatedStorage.xaml"
  4. Right-click on the IsolatedStorageApp in the solution explorer

    1. Choose Add
    2. New Item

    3. Silverlight User Control. In the Name box rename it to IncreaseIsolatedStorage


  5. Meetu

  6. For our purpose we are only taking three textblocks to
    display Space Used, Space Available, Current Quota and the textbox for the New Space request. Add The Following lines in the .xaml file

    <Canvas Canvas.Left="10" Canvas.Top="10">
    <TextBlock Canvas.Left="10" x:Name="SpacedUsed" >Current Spaced Used=</TextBlock>
    <TextBlock Canvas.Left="10" x:Name="SpaceAvaiable" Canvas.Top="20">Current
    Space Available=
    </TextBlock>
    <TextBlock Canvas.Left="10" x:Name="CurrentQuota" Canvas.Top="40">Current
    Quota=
    </TextBlock>
    <TextBlock Canvas.Left="10" x:Name="NewSpace" Canvas.Top="70">New
    space (in bytes) to request=
    </TextBlock>
    <TextBox Canvas.Left="255" Canvas.Top="70" Width="100" x:Name="SpaceRequest"></TextBox>
    <TextBlock Canvas.Left="365" Canvas.Top="70" Width="60">(1048576
    = 1 MB)
    </TextBlock>
    <Button Canvas.Left="10" Content="Increase Storage" Canvas.Top="100" Width="100" Height="50" Click="Button_Click"></Button>
    <TextBlock Canvas.Left="10"
    Canvas.Top
    ="160" x:Name="Result"></TextBlock>
    </Canvas>
  7. Now our page will look like:

    Meetu


  8. To set The Values of the Three TextBlocks lets create a function GetStorageData and call it in the constructor.
    private void GetStorageData()
    {
    //creating an object for the IsolatedStorageFile
    using (IsolatedStorageFile MyAppStore = solatedStorageFile.GetUserStoreForApplication())
    {
    //calculating the space used
    SpacedUsed.Text = "Current Spaced Used = " + (MyAppStore.Quota
    - MyAppStore.AvailableFreeSpace).ToString() + " bytes";
    //getting the AvailableFreeSpace
    SpaceAvaiable.Text = "Current Space Available="
    + MyAppStore.AvailableFreeSpace.ToString() + " bytes";
    //getting the Current Quota
    CurrentQuota.Text = "Current Quota=" + MyAppStore.Quota.ToString() + " bytes";
    }
    }
    Here we will be missing a namespace "System.IO.IsolatedStorage" So include it.

  9. Now the function to increase the quota

    ///
    <summary>
    /// Increases the Isolated Storage Space of the current Application
    /// </summary>
    /// <param name="spaceRequest">
    Total Space Requested to increase
    </param>
    private void IncreaseStorage(long spaceRequest)
    {
    //creating an object for the IsolatedStorageFile for current Application
    using (IsolatedStorageFile MyAppStore = solatedStorageFile.GetUserStoreForApplication())
    {
    //Calculating the new space
    long newSpace = MyAppStore.Quota + spaceRequest;
    try
    {
    //displays a message box for the increase request.
    //if accepted by the user then displays the result as quota increased
    //else unsuccessful.
    if (true == MyAppStore.IncreaseQuotaTo(newSpace))
    {
    Result.Text = "Quota successfully increased.";
    }

else
{
Result.Text = "Quota increase was unsuccessfull.";
}
}
catch (Exception e)
{
Result.Text = "An error occured: " + e.Message;
}
//recalculate the static
GetStorageData();
}
}

Handling the button event
private
void Button_Click(object sender, RoutedEventArgs e)
{
try
{
//taking the space request in the long variable
long spaceRequest = Convert.ToInt64(SpaceRequest.Text);
//calling the function to increase the space
IncreaseStorage(spaceRequest);
}
catch
{
Result.Text = "Bad Data Entered by the user";
}
}

  1. Run the Application and click on the Button after filling the textbox with the desired space to increase.
    A Dialog box will appear for the confirmation click yes to see the results.


    Meetu

Download Code

Thanks and Regards

Meetu Choudhary

My Web My Fourm

Friday, August 14, 2009

Sending Mails with attachments using Gmail

Sending Mails with attachments using Gmail

Many times I came across the question that how can we send mails with some files as attachments and in continuation do we reaky need to buy some domain of our's to send mail or there is a domain using which we can send mails using gmail or yahoo or hotmail accounts. so the answer. So I decided to write this article which will help in solving the above quest.

Let answer First the above questions and then we will code how to send mails with attachments.
Question : Do we need our own domain to send mails?
Answer : No we do not necessarily need our own domain to send mails. Gmail
provides us free pop service and yahoo, hotmail and other mail engines charge for the service. Rather if we have our own domain that would be a benefit.
Question : Can we send files as an attachment?
Answer : Yes we can and even any extension of file can be send as attachment if server allows that as Gmail do not allow to send exe files rest you can send pdf,html,doc etc. any.
Question : Some Times our code is perfectly fine still we are not able to send mails ether we get error failed to send or could not connect to the server what may be the reasons?

Answer : The Reasons is very simple that we have some firewalls or the anti
virus installed on the system which prevents us to do so Specially Mac Fee prevents us sending the mails by blocking the port. The
Remedies is just off the antivirus for some time and then try sending the mail.

Requirements:

Development Machine Requirements
  1. Dotnet installed on the system VS2005 or above The Downloadable version comes for VS2008
  2. Files to attach with the mails
  3. Anti-Virus off while debugging the application
Client Side Requirements
  1. Dotnet Framework 2.0 or above in which the application is made
  2. Browser to run the Application
  3. Anti-Virus off while executing the application

Now lets start developing the application

  1. Create a web application with the name "SendMailWithAttachment". You can even use any name of your choice I am using this for my example.
  2. Add The Following code in the body tag of the Default.aspx page to genrate an interface for the aplication.
    <%@
    Page Language="C#"
    AutoEventWireup="true"
    CodeBehind="Default.aspx.cs"
    Inherits="SendMailWithAttachment._Default"
    %>


    <!DOCTYPE
    html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    <html
    xmlns="http://www.w3.org/1999/xhtml"
    >


    <head
    runat="server">


    <title>Send
    Mail Using Gmail Account With Attachments</title>
    </head>
    <body>
    <form id="Form1" method="post" runat="server">

<table borderColor="#339933" cellSpacing="0" cellPadding="4" width="55%" align="center" border="1">
<tr>
<td>
<table cellPadding="4" width="70%" align="center" border="0"> <tr bgColor="#339933"> <td align="center" colSpan="2"><asp:label id="lblHeader" Runat="server"
Font-Bold="True">Gmail Account Details for Sending Mails</asp:label></td>
</tr>
<tr>
<td vAlign="middle" align="right" width="40%">Username:</td> <td
vAlign="middle" width="60%">
<asp:TextBox
ID="txtUserName" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="350px"></asp:TextBox>
</td>
</tr>
<tr>
<td vAlign="middle" align="right" width="40%">Password</td> <td
vAlign="middle" width="60%">
<asp:TextBox
ID="txtPassword" Font-Names="Verdana" Font-Size="X-Small"
Width="350px" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr bgColor="#339933"> <td align="center" colSpan="2"><asp:label id="Label1" Runat="server"
Font-Bold="True">SMTP
Mail with Attachment</asp:label></td>

</tr>
<tr>
<td vAlign="middle" align="right" width="40%">From :</td> <td vAlign="middle"
width="60%"><asp:textbox id="txtSender"
tabIndex="1" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="350px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="middle" align="right">To :</td>
<td><asp:textbox id="txtReceiver" tabIndex="1"
runat="server" Font-Names="Verdana"
Font-Size="X-Small"
Width="350px"></asp:textbox></td>

</tr>
<tr>
<td vAlign="middle" align="right">Cc :</td>
<td><asp:textbox id="txtCc" tabIndex="1" runat="server"
Font-Names="Verdana" Font-Size="X-Small"
Width="350px"></asp:textbox></td>
</tr>
<tr>
<td vAlign="middle" align="right">Bcc :</td>
<td><asp:textbox id="txtBcc" tabIndex="1" runat="server"
Font-Names="Verdana" Font-Size="X-Small"
Width="350px"></asp:textbox></td>
</tr> <tr>
<td vAlign="middle" align="right">Subject :</td>
<td><asp:textbox id="txtSubject" tabIndex="2" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="350px"></asp:textbox></td>

</tr>
<tr>
<td vAlign="middle" align="right">Format :</td>
<td><asp:radiobuttonlist id="rblMailFormat" tabIndex="3"
runat="server" repeatcolumns="2" repeatdirection="Horizontal">

<asp:ListItem Value="Text" Selected="True">Text</asp:ListItem>
<asp:ListItem Value="HTML">HTML</asp:ListItem>
</asp:radiobuttonlist></td>
</tr>
<tr>
<td vAlign="middle" align="right">Message :</td>
<td height="84"> <p><asp:textbox id="txtBody"
tabIndex="4" runat="server" Font-Names="Verdana" Font-Size="X-Small"
columns="40" rows="5" textmode="MultiLine" width="350px"></asp:textbox></p> </td>
</tr>
<tr>
<td vAlign="middle" align="right">Attachment :</td><td><input id="inpAttachment1" tabIndex="5" type="file" size="53" name="filMyFile" runat="server"></td> </tr>
<tr>
<td vAlign="middle" align="right">Attachment :</td>
<td><input id="inpAttachment2" tabIndex="6" type="file"
size="53" name="filMyFile" runat="server"></td>

</tr>
<tr>
<td vAlign="middle" align="right">Attachment :</td>
<td><input id="inpAttachment3" tabIndex="7" type="file"
size="53" name="filMyFile" runat="server"></td>

</tr>
<tr>
<td align="center" colSpan="2"><asp:button id="btnSend"
tabIndex="9" runat="server" width="100px" text="Send" onclick="btnSend_Click"></asp:button></td>

</tr>
<tr>
<td align="center" colSpan="2"><asp:Label ID="lblMessage"
Runat="server"></asp:Label>

</td>
</tr>
</table>
</td> </tr> </table>
</form>
</body>
</html>


  1. The Default.aspx will now look like:
  2. Now Let us code for the Functionality double Click on the button and the event handler is genrated for the buttonclick
    Before we start the code for the event let us include some namespaces:
    1. using System.Net.Mail;
    2. using System.IO;
    3. using System.Drawing;

      Here is the code for the button event. The code is having inline commets to explain the meamning of each line.

using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Net.Mail;
using
System.IO;
using
System.Drawing;

namespace SendMailWithAttachment
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSend_Click(object sender, EventArgs e)
{

try
{
/* Create a new blank MailMessage with the from and to
adreesses*/

MailMessage mailMessage = new MailMessage txtSender.Text,txtReceiver.Text);
/*Checking the condition that the cc is empty or not if
not then * include them
*/

if (txtCc.Text != null && txtCc.Text != string.Empty)
{
mailMessage.CC.Add(txtCc.Text);
}
/*Checking the condition that the Bcc is empty or not
if not then
* include them
*/

if (txtBcc.Text != null && txtBcc.Text != string.Empty)
{
mailMessage.Bcc.Add(txtBcc.Text);
}
//Ading Subject to the Mail
mailMessage.Subject = txtSubject.Text;
//Adding the Mail Body
mailMessage.Body = txtBody.Text;
/* Set the properties of the MailMessage to the
values on the form as per the mail is HTML formatted or plain text */

if (rblMailFormat.SelectedItem.Text ==
"Text")
mailMessage.IsBodyHtml = false;
else
mailMessage.IsBodyHtml = true;
/* We use the following variables to keep track of
attachments and after we can delete them */

string attach1 = null;
string attach2 = null;
string attach3 = null;
/*strFileName has a attachment file name for
attachment process. */

string strFileName = null;
/* Bigining of Attachment1 process & Check the first open file dialog for a attachment */
if (inpAttachment1.PostedFile != null)
{
/* Get a reference to PostedFile object */
HttpPostedFile attFile = inpAttachment1.PostedFile;
/* Get size of the file */
int attachFileLength = attFile.ContentLength;
/* Make sure the size of the file is > 0 */
if (attachFileLength > 0)
{
/* Get the file name */
strFileName = Path.GetFileName(inpAttachment1.PostedFile.FileName);

/* Save the file on the server */
inpAttachment1.PostedFile.SaveAs(Server.MapPath(strFileName));
/* Create the email attachment with the uploaded file
*/
Attachment attach = new
Attachment(Server.MapPath(strFileName));
/* Attach the newly created email attachment */
mailMessage.Attachments.Add(attach);
/* Store the attach filename so we can delete it later
*/
attach1 = strFileName;
}
}
/* Attachment-2 Repeat previous step defiend above*/
if (inpAttachment2.PostedFile != null)
{
HttpPostedFile attFile = inpAttachment2.PostedFile;
int attachFileLength = attFile.ContentLength;
if (attachFileLength > 0)
{
strFileName = Path.GetFileName(inpAttachment2.PostedFile.FileName); inpAttachment2.PostedFile.SaveAs(Server.MapPath(strFileName));
Attachment attach = new Attachment(Server.MapPath(strFileName));
mailMessage.Attachments.Add(attach);
attach2 = strFileName;
}
}
/* Attachment-3 Repeat previous steps step defiend above*/
if (inpAttachment3.PostedFile != null)
{
HttpPostedFile attFile = inpAttachment3.PostedFile;
int attachFileLength = attFile.ContentLength;
if (attachFileLength > 0)
{
strFileName = Path.GetFileName(inpAttachment3.PostedFile.FileName); inpAttachment3.PostedFile.SaveAs(Server.MapPath(strFileName));
Attachment attach = new Attachment(Server.MapPath(strFileName));
mailMessage.Attachments.Add(attach);
attach3 = strFileName;
}
}
/* Set the SMTP server and send the email with attachment */
SmtpClient smtpClient = new SmtpClient();
// smtpClient.Host = emailServerInfo.MailServerIP;
//this will be the host in case of gamil and it varies from the service provider
smtpClient.Host = "smtp.gmail.com";
//smtpClient.Port = Convert.ToInt32 emailServerInfo.MailServerPortNumber);
//this will be the port in case of gamil for dotnet and
it varies from the service provider

smtpClient.Port = 587;
smtpClient.UseDefaultCredentials = true;
//smtpClient.Credentials = new
System.Net.NetworkCredential(emailServerInfo.MailServerUserName,
emailServerInfo.MailServerPassword);

smtpClient.Credentials = new System.Net.NetworkCredential(txtUserName.Text, txtPassword.Text);
//this will be the true in case of gamil and it varies
from the service provider

smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
/* Delete the attachements if any */
try{

if (attach1 != null)
File.Delete(Server.MapPath(attach1));
if (attach2 != null)
File.Delete(Server.MapPath(attach2));
if (attach3 != null)
File.Delete(Server.MapPath(attach3));

}
catch{}
/* clear the controls */
txtSender.Text = string.Empty;
txtReceiver.Text = string.Empty;
txtCc.Text = string.Empty;
txtBcc.Text = string.Empty;
txtSubject.Text = string.Empty;
txtBody.Text = string.Empty;
txtUserName.Text = string.Empty;
/* Dispaly a confirmation message to the user. */
lblMessage.Visible = true;
lblMessage.ForeColor = Color.Black;
lblMessage.Text = "Message sent.";
}
catch (Exception ex)
{
/* Print a message informing the user about the exception that was risen */
lblMessage.Visible = true;
lblMessage.ForeColor = Color.Red;
lblMessage.Text = ex.ToString();
}
}
}
}

Download code from here





Thanks and Regards

Meetu Choudhary

My Blog My Web My Forums

Saturday, July 25, 2009

Google Code Search

Hey,

Just came across a great link to search codes by Google Here It is

http://www.google.co.in/codesearch

Hope you too will enjoy the searching

One More Great Morning

Meetu: Again a great morning of my life I received the Live meeting accounts and access to e-books
And The Videos Of my MVP Awards Are Already Uploaded Check Them At: My Forums

Thursday, July 2, 2009

Shortcut keys used in Windows operating System

Following are the Shortcut keys used in Windows operating System



Windows system key combinations


F1: Help
CTRL+ESC: Open Start menu
ALT+TAB: Switch between open programs
ALT+F4: Quit program
SHIFT+DELETE: Delete item permanently
Windows Logo+L: Lock the computer (without using CTRL+ALT+DELETE)

Windows program key combinations


CTRL+C: Copy
CTRL+X: Cut
CTRL+V: Paste
CTRL+Z: Undo
CTRL+B: Bold
CTRL+U: Underline
CTRL+I: Italic

Mouse click/keyboard modifier combinations for shell objects


SHIFT+right click: Displays a shortcut menu containing alternative commands
SHIFT+double click: Runs the alternate default command (the second item on the menu)
ALT+double click: Displays properties
SHIFT+DELETE: Deletes an item immediately without placing it in the Recycle Bin

General keyboard-only commands


F1: Starts Windows Help
F10: Activates menu bar options
SHIFT+F10 Opens a shortcut menu for the selected item (this is the same as right-clicking an object
CTRL+ESC: Opens the Start menu (use the ARROW keys to select an item)
CTRL+ESC or ESC: Selects the Start button (press TAB to select the taskbar, or press SHIFT+F10 for a context menu)
CTRL+SHIFT+ESC: Opens Windows Task Manager
ALT+DOWN ARROW: Opens a drop-down list box
ALT+TAB: Switch to another running program (hold down the ALT key and then press the TAB key to view the task-switching window)
SHIFT: Press and hold down the SHIFT key while you insert a CD-ROM to bypass the automatic-run feature
ALT+SPACE: Displays the main window's System menu (from the System menu, you can restore, move, resize, minimize, maximize, or close the window)
ALT+- (ALT+hyphen): Displays the Multiple Document Interface (MDI) child window's System menu (from the MDI child window's System menu, you can restore, move, resize, minimize, maximize, or close the child window)
CTRL+TAB: Switch to the next child window of a Multiple Document Interface (MDI) program
ALT+underlined letter in menu: Opens the menu
ALT+F4: Closes the current window
CTRL+F4: Closes the current Multiple Document Interface (MDI) window
ALT+F6: Switch between multiple windows in the same program (for example, when the Notepad Find dialog box is displayed, ALT+F6 switches between the Find dialog box and the main Notepad window)

Shell objects and general folder/Windows Explorer shortcuts


For a selected object:
F2: Rename object
F3: Find all files
CTRL+X: Cut
CTRL+C: Copy
CTRL+V: Paste
SHIFT+DELETE: Delete selection immediately, without moving the item to the Recycle Bin
ALT+ENTER: Open the properties for the selected object

General folder/shortcut control


F4: Selects the Go To A Different Folder box and moves down the entries in the box (if the toolbar is active in Windows Explorer)
F5: Refreshes the current window.
F6: Moves among panes in Windows Explorer
CTRL+G: Opens the Go To Folder tool (in Windows 95 Windows Explorer only)
CTRL+Z: Undo the last command
CTRL+A: Select all the items in the current window
BACKSPACE: Switch to the parent folder
SHIFT+click+Close button: For folders, close the current folder plus all parent folders

Windows Explorer tree control


Numeric Keypad *: Expands everything under the current selection
Numeric Keypad +: Expands the current selection
Numeric Keypad -: Collapses the current selection.
RIGHT ARROW: Expands the current selection if it is not expanded, otherwise goes to the first child
LEFT ARROW: Collapses the current selection if it is expanded, otherwise goes to the parent

Properties control


CTRL+TAB/CTRL+SHIFT+TAB: Move through the property tabs

Accessibility shortcuts


Press SHIFT five times: Toggles StickyKeys on and off
Press down and hold the right SHIFT key for eight seconds: Toggles FilterKeys on and off
Press down and hold the NUM LOCK key for five seconds: Toggles ToggleKeys on and off
Left ALT+left SHIFT+NUM LOCK: Toggles MouseKeys on and off
Left ALT+left SHIFT+PRINT SCREEN: Toggles high contrast on and off

Microsoft Natural Keyboard keys


Windows Logo: Start menu
Windows Logo+R: Run dialog box
Windows Logo+M: Minimize all
SHIFT+Windows Logo+M: Undo minimize all
Windows Logo+F1: Help
Windows Logo+E: Windows Explorer
Windows Logo+F: Find files or folders
Windows Logo+D: Minimizes all open windows and displays the desktop
CTRL+Windows Logo+F: Find computer
CTRL+Windows Logo+TAB: Moves focus from Start, to the Quick Launch toolbar, to the system tray (use RIGHT ARROW or LEFT ARROW to move focus to items on the Quick Launch toolbar and the system tray)
Windows Logo+TAB: Cycle through taskbar buttons
Windows Logo+Break: System Properties dialog box
Application key: Displays a shortcut menu for the selected item


Microsoft Natural Keyboard with IntelliType software installed


Windows Logo+L: Log off Windows
Windows Logo+P: Starts Print Manager
Windows Logo+C: Opens Control Panel
Windows Logo+V: Starts Clipboard
Windows Logo+K: Opens Keyboard Properties dialog box
Windows Logo+I: Opens Mouse Properties dialog box
Windows Logo+A: Starts Accessibility Options (if installed)
Windows Logo+SPACEBAR: Displays the list of Microsoft IntelliType shortcut keys
Windows Logo+S: Toggles CAPS LOCK on and off


Dialog box keyboard commands


TAB: Move to the next control in the dialog box
SHIFT+TAB: Move to the previous control in the dialog box
SPACEBAR: If the current control is a button, this clicks the button. If the current control is a check box, this toggles the check box. If the current control is an option, this selects the option.
ENTER: Equivalent to clicking the selected button (the button with the outline)
ESC: Equivalent to clicking the Cancel button
ALT+underlined letter in dialog box item: Move to the corresponding item

The above Shortcut keys APPLIES TO


Windows Server 2008 Datacenter
Windows Server 2008 Enterprise
Windows Server 2008 Standard
Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
Microsoft Windows Server 2003, Enterprise x64 Edition
Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
Microsoft Windows Server 2003, Enterprise Edition for Itanium-based Systems
Microsoft Windows Server 2003, Standard x64 Edition
Microsoft Windows Server 2003, Standard Edition (32-bit x86)
Microsoft Windows 2000 Server
Microsoft Windows Millennium Edition
Microsoft Windows 98 Second Edition
Microsoft Windows 98 Standard Edition
Microsoft Windows 95
Windows Vista Business
Windows Vista Enterprise
Windows Vista Home Basic
Windows Vista Home Premium
Windows Vista Starter
Windows Vista Ultimate
Microsoft Windows XP Home Edition
Microsoft Windows XP Professional
Microsoft Windows XP Starter Edition
Microsoft Windows XP Tablet PC Edition

Saturday, June 27, 2009

Empty the Recycle Bin

Empty the Recycle Bin

Ths following code is used to empty the recycle bin using Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio

The namespace we have to use is:

using System.Runtime.InteropServices;
 
then create an enum for recylceflags like
 
enum RecycleFlgs : uint
{
   SHERB_NOCONFIRMATION = 0x00000001,
   SHERB_NOPROGRESSUI   = 0x00000002,
   SHERB_NOSOUND        = 0x00000004
}
 
creating an extern
 
[DllImport("Shell32.dll", CharSet = CharSet.Unicode)]
static extern uint EmptyRecycleBin 
        (IntPtr hwnd, 
        string pszRootPath,
        RecycleFlgs dwFlags);
               
Now the main function to call  the above defined code
 
public static void Main()
{
    uint result = EmptyRecycleBin (IntPtr.Zero, null, 0);
    Console.WriteLine ("Result: {0}", result);
}


Thanks and Regards
Meetu Choudhary
http://www.msdotnetmentor.com/

Thursday, June 18, 2009

Move Cursor to the Last Index in The Texbox

Code for script section in the head

<script type="text/javascript" language="javascript">
function moveindex() {
var me2 = document.selection.createRange();
me2.moveStart("character", 200);
me2.select();
}
</script>

code for calling the function in the body section

<asp:TextBox ID="TextBox1" runat="server" onfocus="moveindex()"/>


Thanks and Regards
Meetu Choudhary

Wednesday, June 17, 2009

Showing Image Dynamically

This piece of code demonstrate that when we take mouse on a particular image the place holder for the image displays the corresponding image... here goes the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

<title>Meetu Choudhary</title>

Script for head section


<script language="javascript" type="text/javascript">

function showimage(imagename)

{

targetimage.src="images/" + imagename;

}

</script>

</head>

Body will have these contents..


<body>
<table width="694" height="525" border="0">

<tr>

<td width="141" height="95" valign="top">

<img src="images/image1.jpg" onmouseover="showimage('image1.jpg')" width="141" height="93">

</td>

<td width="141">

<img src="images/image2.jpg" width="141" height="93" onmouseover="showimage('image2.jpg')">

</td>

<td width="141">

<img src="images/image3.jpg" width="141" height="93" onmouseover="showimage('image3.jpg')">

</td>

<td width="139">

<img src="images/image4.jpg" width="141" height="93" onmouseover="showimage('image4.jpg')">

</td>

<td width="98">

<img src="images/image5.jpg" width="141" height="93" onmouseover="showimage('image5.jpg')">

</td>

</tr>

<tr>

<td height="424">&nbsp;</td>

<td colspan="3" valign="top">

<img id="targetimage" src="images/image1.jpg" width="420" height="252"/>

</td>

<td>&nbsp;</td>

</tr>

</table>

</body>

</html>


To download the zip folder conating the demo of the article click here



Thanks and Regards

Meetu Choudhary

Subscribe via email

Enter your email address:

Delivered by FeedBurner

MSDotnetMentor

MSDotnetMentor My Website http://msdotnetmentor.com