Showing posts with label WebApplication. Show all posts
Showing posts with label WebApplication. Show all posts

Wednesday, 9 November 2011

Deploying the Web Application or Web Service in IIS.

Question Received:
       How to publish the Web Components into the IIS Server 7.0
from 'MicrosoftVisualStudio2010'.

Solution:
      i. Build the Entire Project and solution.
      ii.Right-Click on the project, select 'Build Deployment Package'.
      iii.Right-Click on the project, select 'Publish'.
      iv.Select 'FileSystem' to deploy.
      v. Browse for Target Location.
      vi. Click 'OK' to publish.
      vii.Go to target location and copy the path.
      viii.Start IIS Manager 7.0 ('inetmgr.exe')
      ix.Right-Click 'DefaultWebSite'-->Add Application.
      x. Give the Application Name and TargetPath.
      xi.Browse the Application from InternetExplorer
      
    That's it. Finished.
[Note:] Best Practices,
              --> Choose 'Delete the files in the targetFolder prior to publish'.
              --> Conform building the project and solution prior to publish.

Adding the 'YesNo' MessageBox in the ASP.NetWebApplication

Questions Received:
       How to add the 'YesNo' MessageBox in the ASP.Net WebApplication.

Solution:
       In the 'default.aspx.cs' page,
        private void callMessageBox()
        {
            uscMessageBox.AddMessage("Are you sure that you want update the database?", 
[NameSpace].MessageBox.enmMessageType.Attention, true, true, string.Empty);
        }

        public void MessageAnswered(object sender, [NameSpace].MessageBox.MsgBoxEventArgs e)
        {
            if (e.Answer == [NameSpace].MessageBox.enmAnswer.OK)
            {
            }
            else
            {
            }
        }
      
        In the 'page_load()' method,
             Add, uscMessageBox.MsgBoxAnswered += MessageAnswered; //Event HandlerCaller
       
[Note:] The UpdatePanel will be rendered after the method ends. Parent page control will be lost.
           when the UpdatePanel is displayed.

Tuesday, 8 November 2011

How to add the MessageBox in the ASP.Net WebApplication

Question Received:
       How to add the popup messageBox in the ASP.Net Web Page.

Solution:
       First, Add a new panel over the current page. Panel should hold the
messageBox. It will be refreshed or updated whenever it renders the
messageBox.
       In the 'default.aspx' page, Register the Control Page by,
       <%@ Register 
                      Src="~/MessageBox.ascx" 
                      TagName="uscMsgBox" 
                      TagPrefix="usc" %>
       <asp:Content 
                      ID="BodyContent" 
                      runat="server" 
                      ContentPlaceHolderID="MainContent">
             <usc:uscMsgBox 
                            ID="uscMessageBox" 
                            runat="server" />
       </asp:Content>
       In the 'default.aspx.cs' page, Use the methods like,
        --> uscMessageBox.AddMessage(message [NameSpace].MessageBox.enmMessageType.Error);
        --> uscMessageBox.AddMessage(message [NameSpace].MessageBox.enmMessageType.Info);
       Add the App_Themes with default.css, icons.

       Now compile, It will work.
If Need, You can give the handler to 'OK' Button.
       i. First, write control code in the 'MessageBox.ascx.cs' page.
               protected void btnOK_Click(object sender, EventArgs e)
               {
                  if (ClickedOK != null)
                  {
                      ClickedOK(this, new MsgBoxEventArgs(enmAnswer.OK, Args));
                      Args = "";
                  }
               }
       ii. Add the Handler Event to the 'default.aspx.cs' page.
               uscMessageBox.ClickedOK += OKClick;
       iii. Write handler in the 'default.aspx.cs' page.
               public void OKClick(object sender, [NameSpace].MessageBox.
MsgBoxEventArgs e)
               {
                   if (confirmContinue)
                   {
                        confirmContinue = false;
                        Response.Redirect("default.aspx");               
                   }
               }
        iv. Please make changes in the 'Message.ascx.cs' page.
            OnPreRender()
                //ModalPopUpExtender_OKButton
                     mpeMsg.OkControlID = "btnD2";


  Download source from, YaBu.MessageBox.zip
[Note:] Do above four steps if You want any handler to 'OK' Button.

Extender to any control in the WebApplication

Question Received:
       To add an extender to any control in the web page.

Solution:
       Add it like,
        <asp:RegularExpressionValidator
                                        ID="RegExValidatorCommonGroup"
                                        runat="server"
                                        ControlToValidate="anyTxtBox"
                                        ErrorMessage="Requires valid Text"
                                        ValidationExpression="(Expression_)+[1234]$" 
                                        ValidationGroup="CommonGroup">
       </asp:RegularExpressionValidator>
       <asp:TextBox
                       ID="anyTxtBox"
                       runat="server"
                       Width="250px"
                       ValidationGroup="CommonGroup">
      </asp:TextBox>
     <asp:Button
                   ID="AnyBtn"
                   runat="server"
                   Text="OK"
                   onclick="AnyBtn_Click"
                   ValidationGroup="CommonGroup">  
    </asp:Button>

All Controls in the same group will be triggered for validation.
[Note:] Please do care about the ValidationGroup. Else, All controls in the
page will be triggered for validation.

How to give style to different components in the ASP

Question Received:
        How to give style to the components implicitly without
giving it explicitly in the CSS file.

Solution:
       It can be marked up in the header content as,
    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
        .styleForComponent
        {
            position: absolute;
            right: 4px;
            width: 17px;
            height: 18px;
        }
    </style>
    </asp:Content>
    It can be used in the asp BodyContent as,
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="BodyContent">
    <table style="styleForComponent">
    </asp:Content>

How to register the component or server page

Question Received:
        How to use the AjaxControlToolkit or Control WebPages into ActiveServerPages(.aspx)

Solution:
       First, Register the controls into asp by,
       For any Toolkit,
           <%@ Register 
                           Assembly="AjaxControlToolkit" 
                           Namespace="AjaxControlToolkit" 
                           TagPrefix="asp" %>
       For any Control page,
           <%@ Register 
                           Src="~/MessageBox.ascx" 
                           TagName="uscMsgBox" 
                           TagPrefix="usc" %>

TagName:
      'TagName' is the class that implements the necessary methods.
       For Toolkit,
                  Menu, TabContainer, TabPanel,... are predefined
       For Control page,
                   It is the object created to class implemented in the ctrl page.
              Methods should be implemented for using it explicitly.