Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Ajax
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: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 26-Nov-11 0:28am
Comments
Eduard Lu at 26-Nov-11 5:34am
   
on which part did the error occured? is it in ModalPopupExtender1.Show(); ?
Eduard Lu at 26-Nov-11 5:34am
   
If it is, try my solution
ujjwal uniyal at 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 at 26-Nov-11 5:35am
   
Remove Grid-view From Update Panel And Try..........
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
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 Smile | :)
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 DamithSL 280
1 BillWoodruff 170
2 Zoltán Zörgő 170
3 OriginalGriff 134
4 Sergey Alexandrovich Kryukov 120
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 23 Dec 2013
Copyright © CodeProject, 1999-2014
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