473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

User control inheritance and properties

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
hb******@merc.mercer.edu
Nov 18 '05 #1
2 1224
Hi,

you need to override JavascriptEditFunction in DisInf04 to return
diffrent value. you call from page to JavascriptEditFunction and the
only place it implements is on your base class so base class called.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
hb

"Natty Gur" <na***@dao2com.com> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
Hi,

you need to override JavascriptEditFunction in DisInf04 to return
diffrent value. you call from page to JavascriptEditFunction and the
only place it implements is on your base class so base class called.


Yes, that's what I ended up doing yesterday. I just assumed I could
override the value the property returns, not the property itself. Oh well,
at least I have it figured it out now.

thanks
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mohandas P.M | last post by:
Hi, We have a prob with .Net User Controls, something like this. I have a Custon Control InfoLabel Derived from System.Windows.Forms.Label ( Direct Inheritance - Custom Control) and the some...
5
by: jqpdev | last post by:
Hello all... I'm coming from a Borland Delphi background. Delphi has a specific component called a Data Module. In the designer the Data Module behaves like a windows form. A developer can...
4
by: Mark Goldin | last post by:
I'd like to create a user control (Label and Text box) and modify every instance of that control when I add it to a web page. How can I do that?
1
by: Rob Teegarden | last post by:
I have a class called BasePage that inherits System.Web.UI.Page All my aspx pages inherit a class called BasePage On each page I have a web user control called ClientInfo In the BasePage I...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
8
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.