Search This Blog

Code For Increase & Decrease Image Size...


 

<html>

<head>

    <title>Sample Code</title>

    <script language='javascript'>

    function zoomIncrease()

    {

        document.getElementById('i1').style.height=200;

        document.getElementById('i1').style.width=250;

    }

    function zoomDecrease()

    {

        document.getElementById('i1').style.height=100;

        document.getElementById('i1').style.width=150;

    }

    </script>

</head>

    <body>

    <FORM name="windowEvent">

        <img src="D:\Art\551005.JPG" name="i1" height="100" width="150" onmouseover='zoomIncrease();' onmouseout='zoomDecrease();'> </img>

    </FORM>

    </body>

</html>

Life-Cycle Events in ASP.Net Page

Within each stage of the life cycle of a page, the page raises events that you can handle to run your own code. For control events, you bind the event handler to the event, either declaratively using attributes such as onclick, or in code.

Pages also support automatic event wire-up, meaning that ASP.NET looks for methods with particular names and automatically runs those methods when certain events are raised. If the AutoEventWireup attribute of the @ Page directive is set to true, page events are automatically bound to methods that use the naming convention of Page_event, such as Page_Load and Page_Init. For more information on automatic event wire-up, see ASP.NET Web Server Control Event Model.

The following table lists the page life-cycle events that you will use most frequently. There are more events than those listed; however, they are not used for most page-processing scenarios. Instead, they are primarily used by server controls on the ASP.NET Web page to initialize and render themselves. If you want to write custom ASP.NET server controls, you need to understand more about these events. For information about creating custom controls, see Developing Custom ASP.NET Server Controls.


 

Page Event

Typical Use

PreInit

Raised after the start stage is complete and before the initialization stage begins.

Use this event for the following:

  • Check the IsPostBack property to determine whether this is the first time the page is being processed. The IsCallback and IsCrossPagePostBack properties have also been set at this time.
  • Create or re-create dynamic controls.
  • Set a master page dynamically.
  • Set the Theme property dynamically.
  • Read or set profile property values.

    Note

    If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, its value might be overwritten in the next event.

Init

Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page.

Use this event to read or initialize control properties.

InitComplete

Raised at the end of the page's initialization stage. Only one operation takes place between the Init and InitComplete events: tracking of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event.

Use this event to make changes to view state that you want to make sure are persisted after the next postback.

PreLoad

Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance.

Load

The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page.

Use the OnLoad event method to set properties in controls and to establish database connections.

Control events

Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.

Note

In a postback request, if the page contains validator controls, check the IsValid property of the Page and of individual validation controls before performing any processing.

LoadComplete

Raised at the end of the event-handling stage.

Use this event for tasks that require that all other controls on the page be loaded.

PreRender

Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. (To do this, the Page object calls EnsureChildControls for each control and for the page.)

The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page.

Use the event to make final changes to the contents of the page or its controls before the rendering stage begins.

PreRenderComplete

Raised after each data bound control whose DataSourceID property is set calls its DataBind method. For more information, see Data Binding Events for Data-Bound Controls later in this topic.

SaveStateComplete

Raised after view state and control state have been saved for the page and for all controls. Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback.

Render

This is not an event; instead, at this stage of processing, the Page object calls this method on each control. All ASP.NET Web server controls have a Render method that writes out the control's markup to send to the browser.

If you create a custom control, you typically override this method to output the control's markup. However, if your custom control incorporates only standard ASP.NET Web server controls and no custom markup, you do not need to override the Render method. For more information, see Developing Custom ASP.NET Server Controls.

A user control (an .ascx file) automatically incorporates rendering, so you do not need to explicitly render the control in code.

Unload

Raised for each control and then for the page.

In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.

For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks.


 

Reference : Microsoft MSDN

Making Your Own Web Counter

Step 1.    Create Global.asax file in your application.

Step 2.    In Application_Start Function write the code below

        Application["Hits"] = 0;


 

Step 3.    In Global.asax file's Session_Start function write the code below

        Application.Lock();

        Application["Hits"] = Convert.ToInt32((Application["Hits"].ToString()))+1;

        Application.UnLock();

Step 4.    Now Where ever you want to show the user counter.

  1. Insert a label at that place where you want to show the counter.

    <asp:Label
ID="Lblcounter"
runat="server"
Text=""></asp:Label>


 

  1. IN Page_Load event Write the code below.

        Lblcounter.Text = Application["Hits"].ToString();

Sharepoint Service URL's

URL's For SharePoint Service

http://server/_vti_adm/Admin.asmx - Administrative methods such as creating and deleting sites
http://server/_vti_bin/Alerts.asmx - Methods for working with alerts
http://server/_vti_bin/DspSts.asmx - Methods for retrieving schemas and data
http://server/_vti_bin/DWS.asmx - Methods for working with Document Workspaces
http://server/_vti_bin/Forms.asmx - Methods for working with user interface forms
http://server/_vti_bin/Imaging.asmx - Methods for working with picture libraries
http://server/_vti_bin/Lists.asmx - Methods for working with lists
http://server/_vti_bin/Meetings.asmx - Methods for working with Meeting Workspaces
http://server/_vti_bin/Permissions.asmx - Methods for working with SharePoint Services security
http://server/_vti_bin/SiteData.asmx - Methods used by Windows SharePoint Portal Server
http://server/_vti_bin/Sites.asmx - Contains a single method to retrieve site templates
http://server/_vti_bin/UserGroup.asmx - Methods for working with users and groups
http://server/_vti_bin/versions.asmx - Methods for working with file versions
http://server/_vti_bin/Views.asmx - Methods for working with views of lists
http://server/_vti_bin/WebPartPages.asmx - Methods for working with Web Parts
http://server/_vti_bin/Webs.asmx - Methods for working with sites and subsites

Sending a mail through ASP.Net C#

It is very easy to send email form asp.net or C# Application.

Step 1.

Make a Class (MailSettings.cs)


 

Include these files in that


 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Net.Mail;

using System.Web;

using System.Web.Configuration;

using System.Net.Configuration;

using System.Configuration;


 

Declare these variables in that


 

static
string userName, password, smtpClientHost;

static
int smtpClientPort;

static
bool smtpClientEnableSSL;


 

Create Two functions in that


 

First Function


 

private
static
void setParameters()

{

    try

{


Configuration config = WebConfigurationManager.OpenWebConfiguration("~\\Web.config");

    MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");

        userName = settings.Smtp.Network.UserName;

password = settings.Smtp.Network.Password;

smtpClientHost = settings.Smtp.Network.Host;

smtpClientPort = settings.Smtp.Network.Port;

smtpClientEnableSSL = true;

    }


catch (Exception ex)

{

    throw ex;

    }

}


 

Second Function


 

public
void SendEmail(string mailto string mailFrom, string mailSubject, string mailBody, string mailAttachment)

{

    try

{

    setParameters();


MailMessage msg = new
MailMessage();

msg.From = new
MailAddress(mailFrom);

msg.To.Add(mailto);

msg.Subject = mailSubject;

msg.Body = mailBody;

msg.IsBodyHtml = true;

msg.Attachments.Add(new
Attachment(mailAttachment));

        SmtpClient smtpclient = new
SmtpClient();

smtpclient.EnableSsl = smtpClientEnableSSL;

smtpclient.Host = smtpClientHost;

smtpclient.Port = smtpClientPort;

smtpclient.Send(msg);

    }


catch (Exception ex)

{

    throw ex;

    }

}


 

For sending mail without attachment create third function as second function and make the changes as given below.


 

  1. Remove the last parameter "string mailAttachment";
  2. Remove line "msg.Attachments.Add(new
    Attachment(mailAttachment))";


 

Step 2

Add the given code in the web.config file.


 

<system.net>

    <mailSettings>

        <smtp>

            <network
host="HOST FOR GMAIL"
port="PROT FOR GMAIL"
defaultCredentials="false"
userName="YOUR GMAIL ID"
password="PASSWORD FOR GMAIL" />

        </smtp>

    </mailSettings>

</system.net>


 

Change the code in CAPITAL LETTERS in your own settings.

This code will work only for the gmail email accounts.


 

Step 3

Create in design page as below.


 

Name        :    Name of Sender    <TextBox>

Email        :    Sender's Email ID    <TextBox>

Subject    :    Subject for email    <TextBox>

Body        :    Body for email    <TextArea>

Attachment    :    File Path

        Send & Cancel Buttons


 

Now in the code page, in send button's click event type the code below.

Incude files

using System.Threading;


 

protected
void SendMail_Click(object sender, EventArgs e)

{

    try

{

    string body = MailBodytext();


Thread t = new
Thread(() => mailsend("Receiver's Email" , TxtEmail.Text , txtSubject.Text, body , filepath));

t.Start();

Response.Redirect("Home.aspx");

    }


catch (Exception ex)

{

    throw ex;

    }

}


 

You can also get user's email dynamically from either Hidden field, database or web.config file.


 

protected
void mailsend(string emailto, string emailfrom, string subject, string body)

{

    try

{

        MailSettings mail = new
MailSettings();


bool success = mail.SendEmail(emailto, emailfrom, subject, body, filepath);

    }


catch (Exception ex)

{

    return;

    }

}

private
string MailBodytext()

{


string Body = "";

Body += "<b>Mail By : </b>" + TxtEmail.Text + "<br/>";

Body += "<b>Description : </b><br/>" + txtBody.Text;

    return Body;

}


 


 

Browser Support To HTML5

Here is a site link which checks your browser compatibility

with various tags and api of HTML 5 and CSS 3.

Must check for designers.

http://beta.html5test.com/

India Study Channel

Hi,

If you like to post content online, you may want to try IndiaStudyChannel.com.

Link: http://IndiaStudyChannel.com/r/nipeshshah.aspx

The most attractive feature of the site is, it has a revenue sharing program in association with Google. When you post any content or share your knowledge through various sections like Discussion Forums, 90% of the revenue generated from Google Advertisement in those pages are shared with the authors. Since the revenue sharing program is approved by Google and the revenue is paid to members directly by Google as per AdSense policies, this is a very reliable program. In addition, this site pays and offers various prizes for posting good content.

If you plan to join this site, please use my user id as the referrer since I will get credited for it.

My user id: nipeshshah

regards,

Nipesh Shah

http://www.IndiaStudyChannel.com/r/nipeshshah.aspx

Regular Expression for Restricting Characters

If you are getting the value from the user on a text box/area or something and you don't want user to allow user to enter some characters like html tags(<,>,* etc).

Then it is better to use regular expression which will cause Page Invalid .

For that steps are…

  1. Add one Textbox/area and one RegularExpressionValidator.
  2. Set properties for RegularExpressionValidator.
  3. In ValidationExpression property set value "[^<>/?&{};#]+".

Just Over. This will not allow user to enter the symbols given above. (< , > , / , ? , & , { , } , ; , # ).

You can add or remove other text/symbols/numbers to the above list.

If you want to allow user to enter the characters from certain range then    

  1. In ValidationExpression property set value "^[a-zA-Z]*$".

This will allow user to enter only the characters from a to z and A to Z.

  1. In ValidationExpression property set value "^[a-zA-Z0-9]*$" .

This will allow user to enter only the characters from a to z and A to Z and also 0 to 9.

  1. In ValidationExpression property set value "^[a-zA-Z .]*$" .

This will allow user to enter only the characters from a to z and A to Z Space and Dot. (Ex Mr. Xyz Mno)

Link Within Related Posts Plugin for WordPress, Blogger...
There was an error in this gadget