在asp.net c中的内容页面中调用主页面功能时,主页面控件不在updatepanel中更新 [英] master page control not update in updatepanel when call master page function in content page in asp.net c#

查看:58
本文介绍了在asp.net c中的内容页面中调用主页面功能时,主页面控件不在updatepanel中更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个母版页SiteMaster.Master有一个函数getSMS(),它从数据库中检索sms详细信息并在母版页中绑定,我的问题是有内容页面SendSMS,aspx从这里我发送短信到用户。我的内容页面(sendSMS.aspx)源代码在updatepanel内部,所以当我向用户发送短信时,我调用我的母版页功能getSMS()但主页文字没有改变。



在内容页面代码中调用母版页功能



((SiteMaster)this.Page.Master).getSMS();





我在母版页中的功能



I have a master page SiteMaster.Master there are a function getSMS() which retrive sms detail from database and bind in lable in master page , my problem is that there are content page SendSMS,aspx from here i am send sms to user. my content page(sendSMS.aspx) source code is inside updatepanel so when i send sms to user I call my master page function getSMS() but master page lable text not changed .

calling master page function in content page code

((SiteMaster)this.Page.Master).getSMS();


my function in master page

//Function to check SMS availability
  public void getSMS()
  {
     // int[] sms=new int[2];
      int allSMS=0,sentSMS=0;
      dt = objSMS.selectSMSDetail();
      if (dt != null && dt.Rows.Count > 0)
      {
          //lblSentMsg.Text ="Sent SMS "+ dt.Rows[0]["creditsUsed"].ToString();
          //if (lblSentMsg.Text == string.Empty)
          //{
          //    lblSentMsg.Text = "0";
          //}
          allSMS = Convert.ToInt32(dt.Rows[0]["puchaseSMS"].ToString());
          sentSMS = Convert.ToInt32(dt.Rows[0]["creditsUsed"].ToString());
          allSMS = allSMS - sentSMS;
          Session["SMS"] = allSMS;
          Session["SentSMS"] = sentSMS;
          //lblRemainingMeassage.Text ="Remaining SMS "+ Convert.ToString(allSMS);
          //lblSentMsg.Text = "Sent SMS " +sentSMS;
          Session["SenderId"] = dt.Rows[0]["cenderId"].ToString();
          lblRemainingMeassage.Text = Convert.ToString(allSMS);
          lblSentSMS.Text = Convert.ToString(sentSMS);
          //sms[0] = allSMS;
          //sms[1]=sentSMS;
      }
      //return sms;
  }







如果我删除更新面板它工作但是使用updatepanel它不起作用



请给我解决方案。




if i remove the update panel it work but with updatepanel it not work

please give me solution.

推荐答案

在内容页面上调用母版页功能c#代码

//写下此函数中的所有代码

yourMasterPage m = Master as yourMasterPage;

m.getSMS();

//在内容页面上找到主页面updatepanel并更新它

UpdatePanel upMasterPage =(UpdatePanel) m.FindControl(upMasterPage);

upMasterPage.Update();
call master page function on content page c# code
//write all code in this function
yourMasterPage m = Master as yourMasterPage ;
m.getSMS();
//find master page updatepanel on content page and update it
UpdatePanel upMasterPage = (UpdatePanel)m.FindControl("upMasterPage");
upMasterPage.Update();


这篇关于在asp.net c中的内容页面中调用主页面功能时,主页面控件不在updatepanel中更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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