Solved

vb Code Behind Ajax  Modalpopup Extender button not firing

Posted on 2013-11-19
4
1,156 Views
Last Modified: 2014-01-03
I have a basic page that has 3 radio buttons and a submit. When the submit is clicked, I need the code behind to fire and then mpe.show.

When setting the TargetControlID="Button1", the modalpopup works fine, but the code is not triggered.
When the TargetControlID="Button_Fk" then the code behind works, but the modalpopup does not execute:
Here is the following codes:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" EnableEventValidation="False" SmartNavigation="False"%>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
   
    <h1>
         Warehouse Equipment</h1>
         

    <asp:UpdatePanel ID="mainContentUpdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        Reporting<br />
        <br />
        Select a report-<br />
        <asp:RadioButtonList ID="RadioButtonList1" runat="server" BorderColor="Gray"
            BorderWidth="1px" Width="368px">
            <asp:ListItem Value="1" Selected="True">Master Inventory List</asp:ListItem>
            <asp:ListItem Value="2">Master Inventory and Last Scanned Location</asp:ListItem>
              </asp:RadioButtonList>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Generate Report" CommandArgument = "Button1_Click" />
 
        <asp:Button ID="Button_fk" runat="server" Text="Button" Visible="False" />
           <br />

    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"
             CombineScripts="true">
         </ajaxToolkit:ToolkitScriptManager>
     

    <ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" BehaviorID="mpe" TargetControlID="Button_fk"
                PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="True" >
   
        </ajaxToolkit:ModalPopupExtender>

       
   <asp:Panel ID="Panel1" runat="server" Width="600px" BackColor="white" CssClass="modalpopup"
                ForeColor="Black" Height="400px" Style="text-align: left" BorderColor="Black">
     
   
         <asp:Button ID="Button2" runat="server" Text="Close Window" />
         <br />
   
    <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
            AutoDataBind="true" HasToggleGroupTreeButton="False"
            ToolPanelView="None" />
   
         <br />
   
   
    </asp:Panel>
   
  </ContentTemplate>
  </asp:UpdatePanel>
</asp:Content>


CODE BEHIND-------------------------------------------

 Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click

        mpe.Show()
' EXECUTE SOME CODE TO RUN REPORTS

End sub
0
Comment
Question by:BKennedy2008
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39659741
This line :

<asp:Button ID="Button1" runat="server" Text="Generate Report" CommandArgument = "Button1_Click" />

should be :

<asp:Button ID="Button1" runat="server" Text="Generate Report" OnClick = "Button1_Click" />
0
 

Author Comment

by:BKennedy2008
ID: 39659914
I changed it to that, but that was even a last-minute test adding that line to the button. (either commands do not perform a click function)

When you open the page, the Panel1 is viewed on the page when it is set to the fake button, and when it is set the button1, it is not displayed, even when I have a mpe.hide on page load.
0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 500 total points
ID: 39665068
hi.. this is your solution

Aspx

<ajax:ModalPopupExtender runat="server" ID="modalPop"
            PopupControlID="pnlpopup"
            TargetControlID="btnGo"
              BackgroundCssClass="modalBackground"
             DropShadow="true"
             CancelControlID="btnCancel" X="470" Y="300"   />


//Codebehind    
protected void OkButton_Clicked(object sender, EventArgs e)
    {

        modalPop.Hide();
        //Do something in codebehind
    }

And don't set the OK button as OkControlID.
0
 

Author Comment

by:BKennedy2008
ID: 39674396
I am not sure I see any diffenrence between your code and mine. I am using a fake button for
the target controlID as you are using a button labled  btnGo?
I do not have an OKControlID.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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