Solved

how to trigger a modal popup extender ajaxcontrol to a dropdownlist event?

Posted on 2008-06-18
4
5,175 Views
Last Modified: 2013-11-07
hi there,
im buiding a website on visual studio 2008. and at my usercontrol i have a dropdown list  which has a ModalPopupExtender.
<cc1:ModalPopupExtender ID="dropDownList1_ModalPopupExtender" runat="server"
                DynamicServicePath="" Enabled="True" TargetControlID="dropDownList1"
                    PopupControlID="Panel1"
                    BackgroundCssClass="modalBackground"
                    DropShadow="true"
                    OkControlID="dropDownList1"
                    OnOkScript="showPopup()"
                    CancelControlID="Cancel_Button" >
            </cc1:ModalPopupExtender>

i have followed the example on asp.net ajax control toolkit webisite,  url bellow. http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx

Right now, when the website is running soon as i click at the dropdownlist the panel("panel1") pops up. HOWEVER, i  want is that the panel ("panel1") to be displayed ONLY when the dropdownlist ("dropdowList1") SELECTEDI INDEX IS CHANGED.

can anyone help?
thanks
0
Comment
Question by:RachelDosSantos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:JZoerman
ID: 21824305
Insert a HiddenField object on the page and set it at the target control for the ModalPopupExtender.

Set AutoPostBack on your DropDownList to True

In the SelectedIndexChanged event call the .Show() method for the ModalPopupExtender
<cc1:ModalPopupExtender ID="dropDownList1_ModalPopupExtender" runat="server" 
                    DynamicServicePath="" 
                    Enabled="True" 
                    TargetControlID="HiddenField1"
                    PopupControlID="Panel1" 
                    BackgroundCssClass="modalBackground"
                    DropShadow="true" 
                    CancelControlID="Cancel_Button" >
        </cc1:ModalPopupExtender>
 
 Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        dropDownList1_ModalPopupExtender.Show()
    End Sub

Open in new window

0
 

Author Comment

by:RachelDosSantos
ID: 21863534
hi there,
yeah adding a HiddenField and using it as a targetControl ID, sort of works. But i was thinking of poping up this new window(panel1) without having to post it back to the server.

 Also using this way my javaScript function "showPopup"(ModalPopupExtender property:OnOkScript="showPopup ()"), which passes the value of the usercontrol's dropdownList to the panel's dropdownList doesnt work..

any ideas?
0
 
LVL 2

Accepted Solution

by:
JZoerman earned 500 total points
ID: 21895352
This works...
No postback, passes selected value, and shows modal popup when selected value changes.
Think that covers it, let me know,
JZ
 <script type="text/javascript">    
     function ShowModalPopup(SelectedValue) 
     { 
        alert(SelectedValue);   
        var modal = $find('dropDownList1_ModalPopupExtender'); 
        modal.show(); 
     }
    </script>
 
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        DropDownList1.Attributes.Add("onChange", "ShowModalPopup(this.value)")
    End Sub

Open in new window

0
 

Author Closing Comment

by:RachelDosSantos
ID: 31468312
Excellent stuff,

Yeah that works, thank you so much. You are brilliant!!

Rachel
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question