避免页面刷新网格上LinkBut​​ton的点击,当 [英] Avoid page refresh when clicking on LinkButton in grid

查看:180
本文介绍了避免页面刷新网格上LinkBut​​ton的点击,当的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 GridView控件控件,而这个控件中我已经定义使用链接按钮 GridView.ItemTemplate



我使用这个打开的点击一个新窗口。当我点击了链接按钮,但是,网页打开新窗口之前刷新。



如何从令人耳目一新停止页面的链接按钮被点击后,<? / p>

弹出不显示,当我更新面板添加到第一格



如果我删除从第一格更新面板,网格是清新和弹出窗口显示



我需要打开一个弹出窗口,而无需刷新我的网格



请FIND我要解决的办法,因为我是从事这种由过去2天



HTML

 <%@页面语言=C#AutoEventWireup =假的CodeFile =ViewData1.aspx.cs继承=ablesas.ViewDataUI1EnableEventValidation =假%GT ; 


< ASP:的UpdatePanel ID =UpdatePanel4=服务器>
<&的ContentTemplate GT;

< ASP:GridView控件ID =DataGrid1中的风格=能见度:可见=服务器AlternatingRowStyle-背景色=#E9EDF5FONT-名称=宋体
前景色=#09538AFONT-SIZE =12px的背景色=#FFFFFFBORDERCOLOR =深灰字体粗体=真正的
HeaderStyle-背景色=#298DC7的EnableViewState =假CELLSPACING = 20
CELLPADDING =10HeaderStyle-字体-粗体=真的AutoGenerateColumns =假OnRowCommand =DataGrid1__RowCommandOnRowDataBound =DataGrid1__RowDataBound>
< HeaderStyle字体-名称=宋体;的CssClass =MyHeaderStyleFONT-SIZE =13px的前景色=白字体粗体=真HEIGHT =20背景色=#298DC7>< / HeaderStyle>
< ASP:的TemplateField HEADERTEXT =NDCItemStyle-的CssClass =山坳ItemStyle-Horizo​​ntalAlign =对齐HeaderStyle宽度=10%ItemStyle-WIDTH =10%> <柱体和GT;
<&ItemTemplate中GT;
< ASP:LinkBut​​ton的ID =产品代码前景色=#09538A=服务器文本='<%#的eval(产品代码)%>'>< / ASP: LinkBut​​ton的>

< / ItemTemplate中>
< / ASP:的TemplateField>
< / ASP:GridView的>
< /&的ContentTemplate GT;
< / ASP:的UpdatePanel>


< AjaxToolkit:ModalPopupExtender ID =ModalPopupExtender1BackgroundCssClass =modalBackgroundCancelControlID =取消的TargetControlID =按钮3=服务器PopupControlID =pnlpopup> < / AjaxToolkit:ModalPopupExtender>
< ASP:面板ID =Panel1的=服务器HEIGHT =30像素WIDTH =600px的>
< / ASP:面板>
< ASP:按钮的ID =按钮3=服务器的风格=visibility:hidden的文本=按钮/>
< ASP:面板ID =pnlpopup的CssClass =PanelPopup=服务器>
< DIV的风格=宽度:继承;文本对齐:中心;>%= NDC%GT;的<的产品;产品系列和LT; / DIV>
< ASP:GridView控件ID =GridView1=服务器AlternatingRowStyle-背景色=#f1f4f8WIDTH =980pxFONT-名称=宋体
字体粗体=真前景色=#09538AFONT-SIZE =13px的背景色=#FFFFFFBORDERCOLOR =深灰
HeaderStyle-背景色=#99CCCC的EnableViewState =假CELLSPACING =0的风格=填充:10px的;
的cellpadding =3ShowFooter =假AllowPaging =真的AutoGenerateColumns =FALSEOnRowDataBound =productInfo_RowDataBound>
< HeaderStyle高度=10%的CssClass =MyHeaderStyleFONT-SIZE =13px的前景色=#FFFFFF字体粗体=真正的背景色=#298DC7>< / HeaderStyle> ;
< rowstyle HEIGHT =20像素/>
< alternatingrowstyle HEIGHT =20像素/>
<柱体和GT;
< ASP:BoundField的数据字段=商品条码的SortExpression =客户ItemStyle-的CssClass =山坳HEADERTEXT =NDC/>

< DIV ID =DIV<%#Convert.ToString(EVAL(客户))+ Convert.ToString(EVAL(ManufacturingPartner))+ Convert.ToString(EVAL(产品代码))+ Convert.ToString(EVAL(销售人员))%GT;风格=显示:无;位置:亲属;左:15px的;溢出:汽车>
< ASP:GridView控件ID =gvOrderInfo=服务器前景色=#09538A的AutoGenerateColumns =false的边框样式=双BORDERCOLOR =#df5015WIDTH =500px的OnRowDataBound =gvOrderInfo_RowDatabound >
< HeaderStyle的CssClass =MyHeaderStyleFONT-SIZE =13px的前景色=#FFFFFF字体粗体=真背景色=#298DC7>< / HeaderStyle>
< RowStyle的BackColor =#E1E1E1/>
< AlternatingRowStyle背景色=白/>
< HeaderStyle背景色=#df5015FONT-粗体=真前景色=白/>
<柱体和GT;
< ASP:BoundField的数据字段=订单号的HeaderText =订单号ItemStyle-WIDTH =960x75像素ItemStyle-的CssClass =山坳HeaderStyle-Horizo​​ntalAlign =左/>
< /专栏>
< /专栏>
< / ASP:GridView的>
< / DIV>
< / ASP:GridView的>
< / ASP:面板>



代码隐藏



 保护无效DataGrid1__RowDataBound(对象发件人,GridViewRowEventArgs E)
{
this.UpdatePanel4.Update();
如果(e.Row.RowType == DataControlRowType.DataRow)
{
LinkBut​​ton的LNK = e.Row.FindControl(产品代码)作为LinkBut​​ton的;
lnk.Click + =新的EventHandler(link_Click);

//ScriptManager.GetCurrent(this).RegisterPostBackControl(lnk);

//字符串=的String.Format(0:N},Convert.ToDecimal(e.Row.Cells [3]。文本));
如果(e.Row.Cells [0]。文本!=合计)
{
// M1-Fmodification从这里开始
如果(ListBox2.Items.Count &0)
//如果(DataGrid1.Columns [0]。可见== true)而
{
}
}
}
$} b $ b

代码隐藏

 公共无效productcode_Click(对象发件人,EventArgs五)
{
pnlpopup.Visible = TRUE;
//UpdatePanel3.Update();
//this.UpdatePanel3.Update();
GridViewRow clickedRow =((LinkBut​​ton的)寄件人).NamingContainer为GridViewRow;
的LinkBut​​ton lbtn =(LinkBut​​ton的)clickedRow.FindControl(产品代码);
串顾客= clickedRow.Cells [0] .Text.ToString();
串制造= clickedRow.Cells [5] .Text.ToString();
串售货员= clickedRow.Cells [6] .Text.ToString();
System.Data.DataTable newProductTable = NULL;
ArrayList的productDrilldownList =新的ArrayList();
productDrilldownList.Add(客户);
productDrilldownList.Add(制造商);
productDrilldownList.Add(lbtn.Text);
productDrilldownList.Add(销售人员);



{
ViewData1 VDATA =新ViewData1();
的数据集DS1 = VDATA .__ getProdOverviewDataSet(__ getConnectionString());
的数据集DS2 = VDATA .__ getCustOverviewDataSet(__ getConnectionString());
的数据集DS3 = VDATA .__ getSalesOverviewDataSet(__ getConnectionString());
的数据集DS4 = VDATA .__ getManOverviewDataSet(__ getConnectionString());
的数据集DS5 = VDATA .__ getBookedDateDataSet(__ getConnectionString());

名单,LT; DateTime的> booked_date =新的List<&日期时间GT;();

如果(ds5.Tables [0] .Rows.Count大于0)
{
的foreach(DataRow的行中ds5.Tables [0] .Rows)
{
如果(行[0]的ToString()=与&!&放大器;!行[0] = NULL)
{
booked_date.Add(Convert.ToDateTime(行[0]));
}
}
}
booked_date.Remove(Convert.ToDateTime(1/1/0001 12:00:00 AM));
booked_date.Sort();
ArrayList的日期范围=新的ArrayList();
日期范围= _getDateRange();
如果(Convert.ToDateTime(日期范围的[0])> Convert.ToDateTime(日期范围[1]))
{
// DataGrid1.Visible = FALSE;
// Label4.Visible = FALSE;
// TxtCustProd.Visible = FALSE;
// Panel1.Visible = FALSE;
// ClientScript.RegisterClientScriptBlock(的GetType(),使用Javascript,<脚本>警报(没有找到数据)LT; / SCRIPT>中);
//返回;
}
如果(ToDateTxtBox.Text =!&放大器;&安培;!ToDateTxtBox.Text =最新和放大器;&安培;!FromDateTxtBox.Text =从日期)
{
DropDownList2.Text =月;
DropDownList3.Text =岁月;
如果(booked_date.Contains(Convert.ToDateTime(日期范围[2]))及!&放大器;!booked_date.Contains(Convert.ToDateTime(日期范围[3])))
{
// DataGrid1.Visible = FALSE;
// Label4.Visible = FALSE;
// TxtCustProd.Visible = FALSE;
// Panel1.Visible = FALSE;
// ClientScript.RegisterClientScriptBlock(的GetType(),使用Javascript,<脚本>警报(没有找到数据)LT; / SCRIPT>中);
}
}
,否则
{
ToDateTxtBox.Text =;
FromDateTxtBox.Text =;
}




INT countCustomer = -1;
INT countProduct = -1;
INT countSales = -1;
INT countMan = -1;
如果(ds1.Tables [0] .Rows.Count大于0)
{
countProduct = ds1.Tables [0] .Rows.Count;
}
如果(ds2.Tables [0] .Rows.Count大于0)
{
countCustomer = ds2.Tables [0] .Rows.Count;
}
如果(ds3.Tables [0] .Rows.Count大于0)
{
countSales = ds3.Tables [0] .Rows.Count;
}
如果(ds4.Tables [0] .Rows.Count大于0)
{
countMan = ds4.Tables [0] .Rows.Count;
}


System.Data.DataTable DT =新System.Data.DataTable();
字符串测试=;
如果(会话[callcount]!= NULL){
串COO =会话[callcount]的ToString()。
INT COI = Int16.Parse(COO);
会话[callcount] = COI + 1;
测试=会话[callcount]的ToString()。
}
,否则{
INT COI = 0;
会话[callcount] = coi.ToString();
测试=会话[callcount]的ToString()。
}
DT = VDATA .__ getProductLevelSource(__ getConnectionString(),__getDropDownValues(),__getProdFilterValues(),__getCustFilterValues(),__getSalesFilterValues(),__getManFilterValues(),countCustomer,countProduct,countSales,countMan,_getDateRange() ,__getProdFamilyFilterValues(),productDrilldownList);
GridView1.DataSource = DT;
GridView1.DataBind();
//dt.Rows.Count
Gridview_Columnshide(GridView1);
}
赶上(例外dateerr)
{
//DataGrid1.Visible = FALSE;
//Label4.Visible = FALSE;
//TxtCustProd.Visible = FALSE;
//Panel1.Visible = FALSE;
//ClientScript.RegisterClientScriptBlock(的GetType(),使用Javascript,<脚本>警报(没有找到数据)LT; / SCRIPT>中);

}

ModalPopupExtender1.Show();
//UpdatePanel3.Update();

}


解决方案

请尝试添加模型弹出更新panel.then它会弹出页面进行内部refreshing.this扩展是一个示例代码。这个工作没有任何问题。只是检查一遍

 < ASP:的UpdatePanel =服务器> 
<&的ContentTemplate GT;



< ASP:GridView控件ID =DataGrid1中=服务器OnRowDataBound =DataGrid1__RowDataBound>

<柱体和GT;
< ASP:BoundField的数据字段=ID的HeaderText =值/>
< ASP:的TemplateField的HeaderText =NDCItemStyle-的CssClass =山坳ItemStyle-Horizo​​ntalAlign =对齐HeaderStyle宽度=10%ItemStyle-WIDTH =10%>

<&ItemTemplate中GT;
< ASP:LinkBut​​ton的ID =产品代码前景色=#09538A=服务器文本='点击'>< / ASP:LinkBut​​ton的>

< / ItemTemplate中>
< / ASP:的TemplateField>
< /专栏>
< / ASP:GridView的>



< AjaxToolkit:ModalPopupExtender ID =ModalPopupExtender1的TargetControlID =按钮3=服务器PopupControlID =pnlpopup>< / AjaxToolkit:ModalPopupExtender>

< ASP:按钮的ID =按钮3=服务器风格=visibility:hidden的文本=按钮/>
< ASP:面板ID =pnlpopup的CssClass =模式-BD=服务器>
<输入类型=按钮值=OK>
< / ASP:面板>
< /&的ContentTemplate GT;
< / ASP:的UpdatePanel>



---------- C#---------- -

 保护无效的Page_Load(对象发件人,EventArgs五)
{

数据表DT =新的DataTable();
dt.Columns.Add(ID);
的DataRow博士= dt.NewRow();
的DataRow DR1 = dt.NewRow();
博士[ID] = 1;
DR1 [ID] = 21;
DataGrid1.DataSource = DT;
dt.Rows.Add(DR);
dt.Rows.Add(DR1);
DataGrid1.DataBind();
}
保护无效DataGrid1__RowDataBound(对象发件人,GridViewRowEventArgs E)
{

如果(e.Row.RowType == DataControlRowType.DataRow)
{
LinkBut​​ton的LNK = e.Row.FindControl(产品代码)作为LinkBut​​ton的;
lnk.Click + =新的EventHandler(productcode_Click);


}
}
无效productcode_Click(对象发件人,EventArgs五)
{
pnlpopup.Visible = TRUE;



ModalPopupExtender1.Show();


}


I have a GridView control, and inside of this control I have defined a link button using GridView.ItemTemplate.

I am using this to open a new window on click. When I click on the link button, however, the page refreshes before opening the new window.

How can I stop the page from refreshing after the link button is clicked?

Pop up is not displaying when i add Update panel to first grid

if i remove Update panel from first grid, grid is refreshing and popup is displaying

I need to open a popup without refreshing my grid

PLEASE FIND ME THE SOLUTION FOR THIS AS I WAS WORKING ON THIS FROM PAST 2 DAYS

HTML

<%@ Page Language="c#" AutoEventWireup="false" CodeFile="ViewData1.aspx.cs" Inherits="ablesas.ViewDataUI1" EnableEventValidation="false"%>


            <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                        <ContentTemplate>

                                         <asp:GridView ID="DataGrid1"  style="visibility:visible" runat="server" AlternatingRowStyle-BackColor="#E9EDF5"  Font-Names="Arial"
                                                ForeColor="#09538A" Font-Size="12px" BackColor="#ffffff" BorderColor="DarkGray" Font-Bold="true" 
                                                HeaderStyle-BackColor="#298DC7" EnableViewState="false"  CellSpacing="20" 
                                                CellPadding="10"  HeaderStyle-Font-Bold="true"  AutoGenerateColumns="False" OnRowCommand="DataGrid1__RowCommand" OnRowDataBound="DataGrid1__RowDataBound" >
                                                <HeaderStyle Font-Names="Arial;" CssClass="MyHeaderStyle" Font-Size="13px" ForeColor="White" Font-Bold="True" Height="20"  BackColor="#298DC7" ></HeaderStyle>
        <asp:templatefield headertext="NDC" ItemStyle-CssClass="col" ItemStyle-HorizontalAlign="Justify" HeaderStyle-Width="10%" ItemStyle-Width="10%">                                     <Columns>               
                    <itemtemplate>
                    <asp:linkbutton id="productcode"   ForeColor="#09538A" runat="server"  text='<%#Eval("product code")%>'></asp:linkbutton>                               

                                                     </itemtemplate>
                                        </asp:templatefield>
                   </asp:GridView>
                                </ContentTemplate>
                </asp:UpdatePanel>


                                        <AjaxToolkit:ModalPopupExtender ID="ModalPopupExtender1"   BackgroundCssClass="modalBackground" CancelControlID="cancel" TargetControlID="Button3" runat="server" PopupControlID="pnlpopup"> </AjaxToolkit:ModalPopupExtender>
    <asp:Panel id="Panel1"  runat="server" Height="30px" Width="600px">
    </asp:Panel>        
                   <asp:Button ID="Button3" runat="server" style="visibility:hidden" Text="Button" />
                            <asp:Panel ID="pnlpopup" CssClass="PanelPopup"  runat="server">
                                        <div  style="width:inherit;text-align:center;">Products of <%=ndc %> Product Family</div>
                                        <asp:GridView ID="GridView1"  runat="server" AlternatingRowStyle-BackColor="#f1f4f8"  Width="980px" Font-Names="Arial"
                                            Font-Bold="True" ForeColor="#09538A" Font-Size="13px" BackColor="#ffffff" BorderColor="DarkGray"
                                            HeaderStyle-BackColor="#99cccc" EnableViewState="false"  CellSpacing="0" style="padding:10px;"
                                            CellPadding="3" ShowFooter="false" AllowPaging="True" AutoGenerateColumns="False" OnRowDataBound="productInfo_RowDataBound" >
                                            <HeaderStyle Height="10%" CssClass="MyHeaderStyle" Font-Size="13px" ForeColor="#FFFFFF" Font-Bold="true"  BackColor="#298DC7"></HeaderStyle>
                                            <rowstyle Height="20px" />
                        <alternatingrowstyle  Height="20px"/>
                                            <Columns>
                <asp:boundfield  datafield="product code" sortexpression="customers " ItemStyle-CssClass="col" headertext="NDC"/>

             <div id="div<%#  Convert.ToString(Eval("customer"))+ Convert.ToString(Eval("ManufacturingPartner"))+ Convert.ToString(Eval("product code"))+ Convert.ToString(Eval("Sales Person")) %>" style="display: none; position: relative; left: 15px; overflow: auto">
                                        <asp:GridView ID="gvOrderInfo" runat="server" ForeColor="#09538A"  AutoGenerateColumns="false" BorderStyle="Double"  BorderColor="#df5015"  Width="500px" OnRowDataBound="gvOrderInfo_RowDatabound">
                                        <HeaderStyle CssClass="MyHeaderStyle"  Font-Size="13px" ForeColor="#FFFFFF" Font-Bold="True"  BackColor="#298DC7"></HeaderStyle>
                                        <RowStyle BackColor="#E1E1E1" />
                                        <AlternatingRowStyle BackColor="White" />
                                        <HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
                                        <Columns>
              <asp:BoundField DataField="Order Number" HeaderText="Order Number" ItemStyle-Width="75px" ItemStyle-CssClass="col" HeaderStyle-HorizontalAlign="Left" />
                  </Columns>   
              </Columns>                            
                                        </asp:GridView>
                                    </div>                         
                                            </asp:GridView>
             </asp:Panel>

Codebehind

  protected void DataGrid1__RowDataBound(Object sender, GridViewRowEventArgs e)
    {    
         this.UpdatePanel4.Update();
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
              LinkButton lnk = e.Row.FindControl("productcode") as LinkButton;
              lnk.Click += new EventHandler(link_Click);

              //ScriptManager.GetCurrent(this).RegisterPostBackControl(lnk); 

              // string a = String.Format("0:N}",Convert.ToDecimal(e.Row.Cells[3].Text));
              if (e.Row.Cells[0].Text != "Total")
              {
                    //M1-Fmodification starts from here
                    if (ListBox2.Items.Count > 0)
                    //if (DataGrid1.Columns[0].Visible == true)
                    {
                    }              
              }
         }
    }

Codebehind

 public void productcode_Click(object sender, EventArgs e)
        {
            pnlpopup.Visible = true;
            //UpdatePanel3.Update();
            //this.UpdatePanel3.Update();
            GridViewRow clickedRow = ((LinkButton)sender).NamingContainer as GridViewRow;
            LinkButton lbtn = (LinkButton)clickedRow.FindControl("productcode");
            string customer = clickedRow.Cells[0].Text.ToString();
            string manufacturer = clickedRow.Cells[5].Text.ToString();
            string salesperson = clickedRow.Cells[6].Text.ToString();
            System.Data.DataTable newProductTable = null;
            ArrayList productDrilldownList = new ArrayList();
            productDrilldownList.Add(customer);
            productDrilldownList.Add(manufacturer);
            productDrilldownList.Add(lbtn.Text);
            productDrilldownList.Add(salesperson);


            try
            {
                ViewData1 vData = new ViewData1();
                DataSet ds1 = vData.__getProdOverviewDataSet(__getConnectionString());
                DataSet ds2 = vData.__getCustOverviewDataSet(__getConnectionString());
                DataSet ds3 = vData.__getSalesOverviewDataSet(__getConnectionString());
                DataSet ds4 = vData.__getManOverviewDataSet(__getConnectionString());
                DataSet ds5 = vData.__getBookedDateDataSet(__getConnectionString());

                List<DateTime> booked_date = new List<DateTime>();

                if (ds5.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds5.Tables[0].Rows)
                    {
                        if (row[0].ToString() != " " && row[0] != null)
                        {
                            booked_date.Add(Convert.ToDateTime(row[0]));
                        }
                    }
                }
                booked_date.Remove(Convert.ToDateTime("1/1/0001 12:00:00 AM"));
                booked_date.Sort();
                ArrayList daterange = new ArrayList();
                daterange = _getDateRange();
                if (Convert.ToDateTime(daterange[0]) > Convert.ToDateTime(daterange[1]))
                {
                 //   DataGrid1.Visible = false;
                 //   Label4.Visible = false;
                //    TxtCustProd.Visible = false;
                //    Panel1.Visible = false;
                //    ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('There is no data found')</script>");
                //    return;
                }
                if (ToDateTxtBox.Text != "" && ToDateTxtBox.Text != "To Date" && FromDateTxtBox.Text != "From Date")
                {
                    DropDownList2.Text = "Months";
                    DropDownList3.Text = "Years";
                    if (!booked_date.Contains(Convert.ToDateTime(daterange[2])) && !booked_date.Contains(Convert.ToDateTime(daterange[3])))
                    {
                     //   DataGrid1.Visible = false;
                     //   Label4.Visible = false;
                    //    TxtCustProd.Visible = false;
                    //    Panel1.Visible = false;
                    //    ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('There is no data found')</script>");
                    }
                }
                else
                {
                    ToDateTxtBox.Text = "";
                    FromDateTxtBox.Text = "";
                }




                int countCustomer = -1;
                int countProduct = -1;
                int countSales = -1;
                int countMan = -1;
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    countProduct = ds1.Tables[0].Rows.Count;
                }
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    countCustomer = ds2.Tables[0].Rows.Count;
                }
                if (ds3.Tables[0].Rows.Count > 0)
                {
                    countSales = ds3.Tables[0].Rows.Count;
                }
                if (ds4.Tables[0].Rows.Count > 0)
                {
                    countMan = ds4.Tables[0].Rows.Count;
                }


                System.Data.DataTable dt = new System.Data.DataTable();
                string test = "";
                if(Session["callcount"] != null){
                    string coo = Session["callcount"].ToString(); 
                    int coi = Int16.Parse(coo);
                    Session["callcount"] = coi + 1;
                    test = Session["callcount"].ToString();
                }
                else{
                    int coi = 0;
                    Session["callcount"] = coi.ToString();
                    test = Session["callcount"].ToString();
                }
                dt = vData.__getProductLevelSource(__getConnectionString(), __getDropDownValues(), __getProdFilterValues(), __getCustFilterValues(), __getSalesFilterValues(), __getManFilterValues(), countCustomer, countProduct, countSales, countMan, _getDateRange(), __getProdFamilyFilterValues(), productDrilldownList);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                //dt.Rows.Count
                Gridview_Columnshide(GridView1);
            }
            catch (Exception dateerr)
            {
                //DataGrid1.Visible = false;
                //Label4.Visible = false;
                //TxtCustProd.Visible = false;
                //Panel1.Visible = false;
                //ClientScript.RegisterClientScriptBlock(GetType(), "Javascript", "<script>alert('There is no data found')</script>");

            }

            ModalPopupExtender1.Show();
            //UpdatePanel3.Update();

        }

解决方案

Please try to add the model pop up extender inside the update panel.then it will pop up with out page refreshing.this is a sample code. this one is working without any problem. just check it one more time

  <asp:UpdatePanel runat="server">
    <ContentTemplate>



        <asp:GridView ID="DataGrid1" runat="server" OnRowDataBound="DataGrid1__RowDataBound">

            <Columns>
                <asp:BoundField DataField="ID" HeaderText="Value" />
                <asp:TemplateField HeaderText="NDC" ItemStyle-CssClass="col" ItemStyle-HorizontalAlign="Justify" HeaderStyle-Width="10%" ItemStyle-Width="10%">

                    <ItemTemplate>
                        <asp:LinkButton ID="productcode" ForeColor="#09538A" runat="server" Text='click'></asp:LinkButton>

                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>



        <AjaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" TargetControlID="Button3" runat="server" PopupControlID="pnlpopup"></AjaxToolkit:ModalPopupExtender>

        <asp:Button ID="Button3" runat="server" Style="visibility: hidden" Text="Button" />
        <asp:Panel ID="pnlpopup" CssClass="model-bd" runat="server">
            <input type="button" value="ok">
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>

----------C#------------

   protected void Page_Load(object sender, EventArgs e)
    {

        DataTable dt = new DataTable();
        dt.Columns.Add("ID");
        DataRow dr = dt.NewRow();
        DataRow dr1 = dt.NewRow();
        dr["ID"] = 1;
        dr1["ID"] =21;
        DataGrid1.DataSource = dt;
        dt.Rows.Add(dr);
        dt.Rows.Add(dr1);
        DataGrid1.DataBind();
    }
    protected void DataGrid1__RowDataBound(Object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton lnk = e.Row.FindControl("productcode") as LinkButton;
            lnk.Click += new EventHandler(productcode_Click);


        }
    }
     void productcode_Click(object sender, EventArgs e)
    {
        pnlpopup.Visible = true;



        ModalPopupExtender1.Show();


    }

这篇关于避免页面刷新网格上LinkBut​​ton的点击,当的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆