页面 Repeater 中用了 ImageButton 报错(回发或回调参数无效)
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
回发或回调参数无效。事件验证使用的是启用<页enableeventvalidation =“真正的”/ > < % @页面配置或enableeventvalidation =“真实”% >的一页。为了安全目的,此功能验证回发或回调事件的参数来自服务器控制最初呈现他们。如果数据是有效的和预期,使用clientscriptmanager.registerforeventvalidation方法以便注册回发或回调数据验证。
解决方案:在Page_Load加上一个 if(!IsPostBack)判断后,再绑定数据就可以了。
问题代码:
if (!IsPostBack)
{
string strNick = "杯口留香旗舰店";
//绑定计划下拉框
IList<DCCampaign> mDCCampaignLst = base.DCCampaignService.GetAllByNick(strNick);
drpCampaign.DataSource = mDCCampaignLst;
drpCampaign.DataTextField = "title";
drpCampaign.DataValueField = "campaign_id";
drpCampaign.DataBind();
}
//数据绑定要放在 if (!IsPostBack) 里面,不然会
string strCampaignTitle = drpCampaign.SelectedItem.Text.Trim();
this.BindData(strNick, strCampaignTitle, "", "");
正确代码:
if (!IsPostBack)
{
string strNick = "杯口留香旗舰店";
//绑定计划下拉框
IList<DCCampaign> mDCCampaignLst = base.DCCampaignService.GetAllByNick(strNick);
drpCampaign.DataSource = mDCCampaignLst;
drpCampaign.DataTextField = "title";
drpCampaign.DataValueField = "campaign_id";
drpCampaign.DataBind();
//数据绑定要放在 if (!IsPostBack) 里面,不然会
string strCampaignTitle = drpCampaign.SelectedItem.Text.Trim();
this.BindData(strNick, strCampaignTitle, "", "");
}

浙公网安备 33010602011771号