ASP.NET - Ajax control-modelpopup extender

Asked By chitra ganapathy
30-Jan-12 06:20 AM
i am modelpopup extender with ok and cancel btn for login, i want to add new user btn along with this...
 <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="ModalPopupExtender1"
        runat="server" Enabled="true" PopupControlID="EmpPanel" TargetControlID="EmpPanel"
        OkControlID="btn_OK" CancelControlID="btn_msg" OnOkScript="submit()" OnCancelScript="HideModalPopup()"
        DropShadow="true" BackgroundCssClass="modalback">

here wer i should add for new user btn, plz suggest some idea...
  smr replied to chitra ganapathy
30-Jan-12 06:28 AM
hi

try this code

public event EventHandler LoginStatus;
 bool status;
 
 public Boolean IsLogin
 {
 get { return status; }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
 
 }
 protected void Login(object sender, EventArgs e)
 {
 labMsg.Text = string.Empty;
 
 ModalPopupExtender1.Show(); //show pop up window
 
 if (LoginStatus != null)
 {
 if (txtLogin.Text.Equals("admin") && txtPassword.Text.Equals("admin"))
 {
 status = true;
 
 LoginStatus(this, EventArgs.Empty); //event get fired here.
 
 ModalPopupExtender1.Hide(); //hide pop up window once the user logged in successfully.
 }
 else
 {
 labMsg.Text = "<font color=red>Sorry user name and password could not find</font>";
 }
 }
 }
 public void EnableModelDialog(bool visibility)
 {
 if (visibility)
 {
 ModalPopupExtender1.Show();
 }
 else
 {
 ModalPopupExtender1.Hide();
 }
 }


follow
http://www.codeproject.com/Articles/34996/ASP-NET-AJAX-Control-Toolkit-ModalPopupExtender-Co
http://deepumi.wordpress.com/2010/03/20/asp-net-3-5-ajax-modal-popup-extender-with-user-control-event-bubbling/
  dipa ahuja replied to chitra ganapathy
30-Jan-12 06:29 AM
<cc1:ModalPopupExtender TargetControlID="Button3" BackgroundCssClass="modalBackground"
PopupControlID="Panel1" CancelControlID="LinkButton4" PopupDragHandleControlID="btnMsg"
ID="ModalPopupExtender1" runat="server" />
  
<asp:Button ID="Button3" runat="server" Text="Take Input" />
 
<asp:Panel ID="Panel1" runat="server" Height="80" CssClass="ModalWindow">
<%--Take textboxes here--%>
<asp:LinkButton ID="LinkButton4" runat="server" Text="X" />
Records updated
</asp:Panel>
 
 
  chitra ganapathy replied to dipa ahuja
30-Jan-12 06:34 AM
hi dipa, i want to add 3 buttons in panel.
<asp:Panel ID="EmpPanel" runat="server" BackColor="white" Height="300px" Width="400px"
       Style="display: none"  BorderWidth="1" BorderColor="#108EBF">
        <center>
          <a style="font-family: Verdana; color: #108EBF; font-weight: bold; font-size: 14px;
            position: relative; top: 20px;">Login Panel</a>
          <div id="login" runat="server" style="width: 400px; height: 200px; border: solid 0px red; margin-top: 50px;">
            <div style="width: 300px; height: 40px; border: solid 0px red; float: left">
              <asp:Label ID="lblmsg1" runat="server" ForeColor="#108EBF" Font-Bold="True" Font-Names="verdana"
                Font-Size="11px" Height="25px" Width="100px" Style="left: 0px; position: relative;
                top: 5px">EmailId  :</asp:Label>
              <asp:TextBox ID="txtusername" runat="server" Style="width: 175px; height: 25px;"></asp:TextBox>
            </div>
            <div style="width: 300px; height: 40px; border: solid 0px red; float: left">
              <asp:Label ID="Label1" Text=" Department" runat="server" ForeColor="#108EBF" Font-Bold="True"
                Font-Names="verdana" Font-Size="11px" Height="25px" Width="100px" Style="left: 0px;
                position: relative; top: 5px">Department  :</asp:Label>
              <asp:DropDownList ID="ddldepartment" runat="server" Width="175px" Height="30px">
                <asp:ListItem>Admin</asp:ListItem>
                <asp:ListItem>Accounts</asp:ListItem>
                <asp:ListItem>Software</asp:ListItem>
                <asp:ListItem>LED</asp:ListItem>
                <asp:ListItem>Video</asp:ListItem>
                <asp:ListItem>Structure</asp:ListItem>
                <asp:ListItem>Logistics</asp:ListItem>
                <asp:ListItem>Creative</asp:ListItem>
                <asp:ListItem>Desinging</asp:ListItem>
              </asp:DropDownList>
            </div>           
          </div>
          <div id="newuser" runat="server" style="width: 400px; height: 200px; border: solid 0px red; margin-top: 50px;">
            <div style="width: 300px; height: 40px; border: solid 0px red; float: left">
              <asp:Label ID="Label5" runat="server" ForeColor="#108EBF" Font-Bold="True" Font-Names="verdana"
                Font-Size="11px" Height="25px" Width="100px" Style="left: 0px; position: relative;
                top: 5px">EmailId  :</asp:Label>
              <asp:TextBox ID="txtnewuser" runat="server" Style="width: 175px; height: 25px;"></asp:TextBox>
            </div>
            <div style="width: 300px; height: 40px; border: solid 0px red; float: left">
              <asp:Label ID="Label6" runat="server" Text="Password" ForeColor="#108EBF" Font-Bold="True"
                Font-Names="verdana" Font-Size="11px" Height="25px" Width="100px" Style="left: 0px;
                position: relative; top: 5px"></asp:Label>
              <asp:TextBox ID="TextBox2" runat="server" Style="width: 175px; height: 25px;"></asp:TextBox>
            </div>
            <div style="width: 300px; height: 40px; border: solid 0px red; float: left">
              <asp:Label ID="Label7" runat="server" Text="Confirm Password" ForeColor="#108EBF" Font-Bold="True"
                Font-Names="verdana" Font-Size="11px" Height="25px" Width="100px" Style="left: 0px;
                position: relative; top: 5px"></asp:Label>
              <asp:TextBox ID="TextBox3" runat="server" Style="width: 175px; height: 25px;"></asp:TextBox>
            </div>          
          </div>
         <div style="width: 300px; height: 40px; border: solid 0px red; float: left">
              <asp:Button ID="btn_OK" runat="server" Text="Ok" OnClick="btn_OK_Click" Style="left: 0px;
                position: relative; top: 10px;" />
              <asp:Button ID="btn_msg" runat="server" Text="Cancel" Style="left: 0px; position: relative;
                top: 10px;" />
           <asp:Button ID="btn_newuser" runat="server" Text="New User" Style="left: 0px; position: relative;
                top: 10px;" onclick="btn_newuser_Click"  />
         </div>
         <asp:Label ID="lblerrormsg" runat="server" Width="150px" Height="30px"></asp:Label>
        </center>
      </asp:Panel>
      <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="ModalPopupExtender1"
        runat="server" Enabled="true" PopupControlID="EmpPanel" TargetControlID="EmpPanel"
        OkControlID="btn_OK" CancelControlID="btn_msg" OnOkScript="submit()" OnCancelScript="HideModalPopup()"
        DropShadow="true" BackgroundCssClass="modalback">
      </ajaxToolkit:ModalPopupExtender>

here how to use btn_newuser
  dipa ahuja replied to chitra ganapathy
30-Jan-12 06:41 AM
For modalpopup, you required properties are :


TargetControlID: This is the property which sets the ID of control using which we can display the Popup (Required) PopupControlID: This is the property which sets the ID of control which will be popped up after clicking on the

TargetControlID control. (Required) Here we took the Button but we are not showing this button on webpage, we took this because the property of ModalPopup “TargetControlID” is required to set.
  Vickey F replied to chitra ganapathy
30-Jan-12 06:45 AM

use modalPopUpExtender like this-


<asp:Button ID="btnpopup" runat="server" Text="Button" />

<ajaxtoolkit:modalpopupextender id="mpe" runat="server" targetcontrolid="btnpopup"
popupcontrolid="pnlpopup" cancelcontrolid="btnCancelpopup" enableviewstate="true" />

<asp:Panel ID="pnlpopup" runat="server" style="display: none" >
test
<asp:Button ID="btnCancelpopup" runat="server" Text="Button" />
</asp:Panel>

Try this code and let me know.

  R B replied to chitra ganapathy
30-Jan-12 06:49 AM

Hello,

 

You can use javascript $find('modalpopupbehavior').hide() to close it.

Please check this: http://forums.asp.net/t/1424343.aspx 

You don't need care of how many okControl. If you want to close it, you can define OnClientClick event of button to call javascript $find('modalpopupbehavior').hide().

 

 

 

 

Hope this is helpful !

Thanks

 

 

 

 

 

  James H replied to chitra ganapathy
30-Jan-12 06:52 AM
It is possible for a ModalPopupExtender to be displayed using a postback. You'll need an invisible target control. The extender is attached to this hidden control.
<asp:Button runat="server" ID="btnShowModal" Text="Show"
OnClick="btnShowModal_Click" />
<asp:Button runat="server" ID="HiddenForModal" style="display: none" />
<ajaxToolKit:ModalPopupExtender ID="Modal1" runat="server"
TargetControlID="HiddenForModal" PopupControlID="PopupPanel" />

In your message handler in code-behind, you'll show the ModalPopupExtender:
Modal1.Show();


And in the code you're using to dismiss the Modal, call the ModalPopupExtender's Hide function:

Modal1.Hide();
  Web Star replied to chitra ganapathy
30-Jan-12 06:58 AM
this is not possible with modalpopupextender control it has only two option ok and calncel buton , if you want to your customzed layout with other option than make your user control and open that in popup page simply
see below there only ok and cancel button support with this control

The control above is initialized with this code. The display on the modal popup element is set to none to avoid a flicker on render. The italic properties are optional:

<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
    TargetControlID="LinkButton1"
    PopupControlID="Panel1"
    BackgroundCssClass="modalBackground" 
    DropShadow="true" 
    OkControlID="OkButton" 
    OnOkScript="onOk()"
    CancelControlID="CancelButton" 
    PopupDragHandleControlID="Panel3" >
        <Animations>
            <OnShowing> ..  </OnShowing>
            <OnShown>   ..  </OnShown>    
            <OnHiding>  ..  </OnHiding>            
            <OnHidden>  ..  </OnHidden>            
        </Animations>
    </ajaxToolkit:ModalPopupExtender>
    
  • TargetControlID - The ID of the element that activates the modal popup
  • PopupControlID - The ID of the element to display as a modal popup
  • BackgroundCssClass - The CSS class to apply to the background when the modal popup is displayed
  • DropShadow - True to automatically add a drop-shadow to the modal popup
  • OkControlID - The ID of the element that dismisses the modal popup
  • OnOkScript - Script to run when the modal popup is dismissed with the OkControlID
  • CancelControlID - The ID of the element that cancels the modal popup
  • OnCancelScript - Script to run when the modal popup is dismissed with the CancelControlID
  • PopupDragHandleControlID - The ID of the embedded element that contains the popup header/title which will be used as a drag handle
  • X - The X coordinate of the top/left corner of the modal popup (the popup will be centered horizontally if not specified)
  • Y - The Y coordinate of the top/left corner of the modal popup (the popup will be centered vertically if not specified)
  • RepositionMode - The setting that determines if the popup needs to be repositioned when the window is resized or scrolled.
  kalpana aparnathi replied to chitra ganapathy
30-Jan-12 08:53 AM
  1. You want to make sure that one and only one ScriptManager control is on the page.

  2. To create a modal popup you have to insert the text you want to display in the modal popup in an Asp.Net Panel control.

    <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" style="display:none;">
    This is basic modal popup.
    <br /><br />
    <asp:Button ID="btnOk" runat="server" Text="Ok" />
    <asp:Button ID="btnClose" runat="server" Text="Close Me" />
    </asp:Panel>


  3. Notice that I set display:none for the style of the Asp:Panel control. This prevents the Asp:Panel from being displayed for a brief second when the page is loading.

  4. To display the modal popup you have to create an Asp.Net control that will display the modal popup when clicked.

    <asp:Button ID="Button1" runat="server" Text="First Modal Popup" />

  5. Add the ModalPopupExtender control. Here is an example to what I set the attributes to.

    <ajaxToolkit:ModalPopupExtender
    BackgroundCssClass="modalBackground"
    DropShadow="true"
    OkControlID="btnOk"
    CancelControlID="btnClose"
    runat="server"
    PopupControlID="Panel1"
    id="ModalPopupExtender1"
    TargetControlID="Button1" />


  6. Notice the BackgroundCssClass for the ModalPopupExtender. This class is used to give that grayed out overlay of the page while the modal popup is displayed.
    The style used for the ModalPopupExtender is below:

    .modalBackground {
    background-color:#fff;
    filter:alpha(opacity=70);
    opacity:0.7px;
    }


  7. Then second modal popup runs Javascript when the close button is clicked. To achieve this you just need to add the OnCancelScript attribute. You can also use OnOkScript if you want the Javascript to run when the Ok button is clicked.
    The value you put for the attribute is the Javascript function you want to run. For example: OnCancelScript="CloseScript()"
Create New Account
help
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are
asp.net in c# how to create pops in asp.net. . . . .i want pops ups like registration form appears when we click on a register link make a best use of ajax modalpopupextender. Download ajax toolkit from following link http: / / www.asp.net / ajax Just follow the steps given in above link and you will be able to poup the window for registration just put your all controls in asp.net panel and then give popuid to modelpopup extnder Hope this helps you thank you You
Pop up window using AJAX in ASP.NET Pop up window using AJAX in ASP.NET Refer: http: / / www.asp.net / ajax / ajaxcontroltoolkit / Samples / PopupControl / PopupControl.aspx Untitled document < cc1 : ModalPopupExtender TargetControlID = "Button3" BackgroundCssClass = "modalBackground" PopupControlID user logged in Successfully the user control event get fired in the Login Control ASCX page which is subscribed in the parent ASPX page. Following are the screen shots for login control page and aspx page. For more information
Problems with FormsAuthentication in simple form Below is a very simple asp page that has a loginstatus control and button used to login the user in. The problem is I have to press the login button twice to get the loginstatus control to update. I even tried loginstatus.databind() in the button code but it didn't seem to matter. Obviously the login control has this figured out. What am I missing? thanks (posted on asp.net also but with no help offered) [CODE] <%@ Page Language = "C#" %> <!DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / / EN" "http: / / www.w3 org / TR / xhtml1 / DTD / xhtml1-transitional.dtd"> <script runat = "server"> protected void Button1_Click(object sender, EventArgs e) { if (Membership.ValidateUser("theuser", "thepassword")) { / / could have a profile option for remember me here