Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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


XML
<form id="form1" runat="server">
  <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
  </asp:ToolkitScriptManager>

  <asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>
    <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">
        <Columns>
            <asp:TemplateField HeaderText="Name">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkbtnName" runat="server" Text='<%# Eval("Name") %>' OnClick="lnkbtnName_Click"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Company" HeaderText="Company" />
        </Columns>
        <FooterStyle BackColor="Tan" />
        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
            HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
    </asp:GridView>

  <br />
  <br />
 <asp:Button runat="server" ID="btnModalPopUp"
          style="display:none"/>
    <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnModalPopUp" PopupControlID="pnlPopUp" OkControlID="btnOk" X="60" Y="100">
    </asp:ModalPopupExtender>

    <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:GridView>
    </asp:Panel>

</ContentTemplate>

  </asp:UpdatePanel>

  <asp:SqlDataSource ID="SqlDataSource1" runat="server"
      ConnectionString="<%$ ConnectionStrings:ujjwalConnectionString %>"
      SelectCommand="SELECT * FROM [Employee] ORDER BY [ID]"></asp:SqlDataSource>

  </form>




.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)
    {
        con.Close();
    }
    
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void lnkbtnName_Click(object sender,   EventArgs  e)
    {
        con.Open();
        LinkButton lnkbtnName=  sender as LinkButton ;
        string Name =  lnkbtnName.Text ;
        
        da = new SqlDataAdapter("Select * from Employee where Name ='"+ Name +"' ", con );
       DataSet ds = new DataSet() ;
        da.Fill(ds);
        GridView2.DataSource= ds;
        GridView2.DataBind();
        con.Close();
        ModalPopupExtender1.Show();
    
    }
}
Posted
Comments
[no name] 26-Nov-11 5:34am    
on which part did the error occured? is it in ModalPopupExtender1.Show(); ?
[no name] 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..........

It started working for me by just changing the Toolkit Script Manger "Script Mode to Release" from the Propoerty window.
 
Share this answer
 
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 :)
 
Share this answer
 
Hi,

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,
Eduard
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900