H
hb
Situation: A variable is declared with a default value in base user
control. The control that inherits from the control may want to change the
values. Here is how I currently have it set up (condensed to essential
code):
======= BASE USER CONTROL ========
public class Base107RequestSubform : System.Web.UI.UserControl {
protected string _jsEditFunction = "DoNothing();";
public string JavascriptEditFunction {
get {
return _jsEditFunction;
}
}
}
======= INHERITED CONTROL ========
public abstract class DisInf04 : DiscrepancyInfo // DiscrepancyInfo class
inherits from Base107RequestSubform, so DisInf04 is a "grandchild" of
Base107RequestForm
{
new protected string _jsEditFunction = "ToggleDiscrepancyEdit();";
}
======= ASPX PAGE THAT LOADS CONTROL DYNAMICALLY =========
// code is in Page_Init event
// subformClass is a string and it's pulled from DB
discrepancyInfoControl = (_107RequestForm.DiscrepancyInfo)
this.Page.LoadControl( String.Format( "107RequestForm/{0}.ascx",
subformClass ) );
subformPanel.Controls.Add( discrepancyInfoControl );
lnkToggleEdit.NavigateUrl = "javascript: " +
discrepancyInfoControl.JavascriptEditFunction;
===============
So my problem is that the value "ToggleDiscrepancyEdit();" is not being
pulled in this line:
lnkToggleEdit.NavigateUrl = "javascript: " +
discrepancyInfoControl.JavascriptEditFunction;
Instead, it's getting the value "DoNothing();" from the base class. What am
I missing here? I have tried putting that line in other page events, like
Load and PreRender, but nothing has worked so far.
--
Hillarie Branyan
Mercer Engineering Research Center
478.953.6800 x2505
(e-mail address removed)
control. The control that inherits from the control may want to change the
values. Here is how I currently have it set up (condensed to essential
code):
======= BASE USER CONTROL ========
public class Base107RequestSubform : System.Web.UI.UserControl {
protected string _jsEditFunction = "DoNothing();";
public string JavascriptEditFunction {
get {
return _jsEditFunction;
}
}
}
======= INHERITED CONTROL ========
public abstract class DisInf04 : DiscrepancyInfo // DiscrepancyInfo class
inherits from Base107RequestSubform, so DisInf04 is a "grandchild" of
Base107RequestForm
{
new protected string _jsEditFunction = "ToggleDiscrepancyEdit();";
}
======= ASPX PAGE THAT LOADS CONTROL DYNAMICALLY =========
// code is in Page_Init event
// subformClass is a string and it's pulled from DB
discrepancyInfoControl = (_107RequestForm.DiscrepancyInfo)
this.Page.LoadControl( String.Format( "107RequestForm/{0}.ascx",
subformClass ) );
subformPanel.Controls.Add( discrepancyInfoControl );
lnkToggleEdit.NavigateUrl = "javascript: " +
discrepancyInfoControl.JavascriptEditFunction;
===============
So my problem is that the value "ToggleDiscrepancyEdit();" is not being
pulled in this line:
lnkToggleEdit.NavigateUrl = "javascript: " +
discrepancyInfoControl.JavascriptEditFunction;
Instead, it's getting the value "DoNothing();" from the base class. What am
I missing here? I have tried putting that line in other page events, like
Load and PreRender, but nothing has worked so far.
--
Hillarie Branyan
Mercer Engineering Research Center
478.953.6800 x2505
(e-mail address removed)