ASCX
<dx:ASPxGridViewExporter ID="ASPxGridViewExporter1" runat="server">
</dx:ASPxGridViewExporter>
<dx:ASPxButton ID="buttonSaveAs" runat="server" ToolTip="Export and save" Style="vertical-align: middle;"
OnClick="buttonSaveAs_Click" Text="Save" Width="51px" />
包含ASCX以上的ASPX
<div>
//ASCX
</div>
<div>
<dx:ASPxPivotGrid ID="ASPxPivotGridElectricMeterReadings" runat="server" ClientIDMode="AutoID"
DataSourceID="SqlDataSourceElectricMeterReadings" EnableCallBacks="False" Width="1000px">
</dx:ASPxPivotGrid>
</div>
ASCX.cs
protected void buttonSaveAs_Click(object sender, EventArgs e)
{
// I want to get pivotGridId from ASPX
ASPxGridViewExporter1.ASPxPivotGridID = ASPX-PivotGrid-ID
}
如何将ASPX控件ID传递给ASCX button_click_event?
答案 0 :(得分:1)
只需在后面的ascx代码中添加一个属性,然后在aspx initialize事件中填充它。
<强> ASCX.cs 强>
public string PivotGridID { get; set; }
<强> ASPX.cs 强>
if (!IsPostBack)
{
exportPivotGrid.PivotGridID = ASPxPivotGridElectricMeterReadings.ID;
}
答案 1 :(得分:0)
在页面加载事件(用户控件)中尝试声明父控件,并且必须在回发事件之外。
(this.Parent.Parent).FindControl("ErrLabel") as Label;