Click here to Skip to main content
13,086,264 members (87,809 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all!!

i am trying to open a popup open user clicks a button inside gridview. I am using AJAX ModelPopUpExtender. When i am running the project it's not showing me any error but it's not working too. However when i applied breakpoints it says -:

"There is no source code available for the current location."

please help me out. I have registered the tool kit in case u want to know.

.aspx code

<form id="form1" runat="server">
  <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px"
        CellPadding="2" DataSourceID="SqlDataSource1" ForeColor="Black"
        GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged" DataKeyNames="Name">
            <asp:TemplateField HeaderText="Name">
                    <asp:LinkButton ID="lnkbtnName" runat="server" Text='<%# Eval("Name") %>' OnClick="lnkbtnName_Click"></asp:LinkButton>
            <asp:BoundField DataField="Company" HeaderText="Company" />
        <FooterStyle BackColor="Tan" />
        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
            HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
  <br />
  <br />
 <asp:Button runat="server" ID="btnModalPopUp"
    <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnModalPopUp" PopupControlID="pnlPopUp" OkControlID="btnOk" X="60" Y="100">
    <asp:Panel runat="server" ID="pnlPopUp">
    <asp:GridView runat="server" ID="GridView2" AutoGenerateColumns="False"
            CellPadding="4" ForeColor="#333333" GridLines="None">
        <RowStyle BackColor="#EFF3FB" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        <AlternatingRowStyle BackColor="White" />
  <asp:SqlDataSource ID="SqlDataSource1" runat="server"
      ConnectionString="<%$ ConnectionStrings:ujjwalConnectionString %>"
      SelectCommand="SELECT * FROM [Employee] ORDER BY [ID]"></asp:SqlDataSource>

.aspx.cs code

public partial class ModelPopUpExtender : System.Web.UI.Page
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ujjwalConnectionString"].ConnectionString);
    SqlDataAdapter da;
    protected void Page_Load(object sender, EventArgs e)
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    protected void lnkbtnName_Click(object sender,   EventArgs  e)
        LinkButton lnkbtnName=  sender as LinkButton ;
        string Name =  lnkbtnName.Text ;
        da = new SqlDataAdapter("Select * from Employee where Name ='"+ Name +"' ", con );
       DataSet ds = new DataSet() ;
        GridView2.DataSource= ds;
Posted 25-Nov-11 23:28pm
Eduard Lu 26-Nov-11 5:34am
on which part did the error occured? is it in ModalPopupExtender1.Show(); ?
Eduard Lu 26-Nov-11 5:34am
If it is, try my solution
ujjwal uniyal 26-Nov-11 5:39am
i solved it by myself sir.

anyways thanks for giving me a tip. maybe it will help me in future
Tushar_Patil 26-Nov-11 5:35am
Remove Grid-view From Update Panel And Try..........
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


btnModalPopUp is the control's targetcontrolid. Add a hiddenfield and use the hidden field's ID as the targetcontrolid of the modal popup extender. This will fix your problem.

Also, make your panel visible for double checking by adding:
pnlPopUp.Visible = true;

And also, check if the containing gridview is not empty, cause if it is, the popup won't show.

Please mark as answer if this fixed your problem

Best regards,
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I solved it..

i didn't added the buttons to be used as ok and cancel inside the panel that's why it was not doing anything.

Silly me.

By the way thanks to all of you for help :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

It started working for me by just changing the Toolkit Script Manger "Script Mode to Release" from the Propoerty window.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 23 Dec 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100