|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
asp.net custom server control not showing when dragged onto web foI've created a custom composite calendar server control in asp.net. I've
compiled the dll and added it to my toolbox, but when I drag and drop it onto a web form, I don't see the control in the designer. All I can see is a tiny little green arrow. It shows up in the property explorer for the page and the control works just fine when the page is rendered on a browser. The problem is that I don't see it on the form in the vs.net web form designer and that is perplexing. Anyone have any ideas on why this is happening and what I can do to fix it? Hi Spencer,
Welcome to ASPNET newsgroup. From your description, you're developing a custom webserver control (composite control) which will contain a Calendar inside it. However when you draged the control on a webform page at design-time you found it displayed nothing on the webform's design-view, yes? Based on my understanding, what you have encountered was the expected behavior. This is because by default, VS.NET will call the Control's Render method get the html displayed in design-view. And for Composite control, we used CreateChildControls to construct the control hierarchy rather than using Render method , so you'll get the empty(an arrow only) in design-view. If we do need to provide our customized Html View for our control at design-view, we can consider creating a custom control designer for our composite control. For example: we can apply a custom ControlDesigner class for a custom control like: [ Designer("CustomControls.Design.SimpleDesigner, CustomControls.Design")] public class Simple : WebControl { .................... } And we can override the "GetDesignTimeHtml() " method of the ControlDesigner class which is used to return the html code to display in IDE at design-time. For detailed description, you can refer to the following MSDN document: #Implementing a Simple Web Forms Control Designer http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmldesignersample .asp?frame=true Hope helps. Thanks, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) Steve,
Thanks for the reply, you are correct in your diagnosis of the problem. The code in the article you provided a link to seems as though it should work. One problem with it though - I cannot import System.Web.UI.Design or inherit from System.Web.UI.Design.ControlDesigner. Also, I'm not sure what the CustomControls library is that is imported in the example, but I cannot import that either. Am I missing a reference or a file or something? Please let me know the answer to this question and it should answer my initial one. Thanks. Spencer Show quoteHide quote "Steven Cheng[MSFT]" wrote: > Hi Spencer, > > Welcome to ASPNET newsgroup. > From your description, you're developing a custom webserver control > (composite control) which will contain a Calendar inside it. However when > you draged the control on a webform page at design-time you found it > displayed nothing on the webform's design-view, yes? > > Based on my understanding, what you have encountered was the expected > behavior. This is because by default, VS.NET will call the Control's Render > method get the html displayed in design-view. And for Composite control, we > used CreateChildControls to construct the control hierarchy rather than > using Render method , so you'll get the empty(an arrow only) in > design-view. > > If we do need to provide our customized Html View for our control at > design-view, we can consider creating a custom control designer for our > composite control. For example: > > we can apply a custom ControlDesigner class for a custom control like: > > [ Designer("CustomControls.Design.SimpleDesigner, CustomControls.Design")] > public class Simple : WebControl { > .................... > } > > And we can override the "GetDesignTimeHtml() " method of the > ControlDesigner class which is used to return the html code to display in > IDE at design-time. For detailed description, you can refer to the > following MSDN document: > > #Implementing a Simple Web Forms Control Designer > http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmldesignersample > .asp?frame=true > > Hope helps. Thanks, > > Steven Cheng > Microsoft Online Support > > Get Secure! www.microsoft.com/security > (This posting is provided "AS IS", with no warranties, and confers no > rights.) > > Hi Spencer,
The "CustomControls.Design" in the example is just a test namespace, we don't need to care about it. And the ControlDesigner class is under the System.Web.UI.Design namespace. However, the System.Web.UI.Design namespace are not in the same assembly with the System.Web.UI namespace. We need to add reference of the System.Design.dll (contains the System.Web.UI.Design namespace) first. Thanks & Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) Yup, that did it. Too bad the ms article didn't mention that. Thanks for
the help. Show quoteHide quote "SpencerW" wrote: > Steve, > Thanks for the reply, you are correct in your diagnosis of the problem. The > code in the article you provided a link to seems as though it should work. > One problem with it though - I cannot import System.Web.UI.Design or inherit > from System.Web.UI.Design.ControlDesigner. Also, I'm not sure what the > CustomControls library is that is imported in the example, but I cannot > import that either. Am I missing a reference or a file or something? Please > let me know the answer to this question and it should answer my initial one. > Thanks. > > Spencer > > > "Steven Cheng[MSFT]" wrote: > > > Hi Spencer, > > > > Welcome to ASPNET newsgroup. > > From your description, you're developing a custom webserver control > > (composite control) which will contain a Calendar inside it. However when > > you draged the control on a webform page at design-time you found it > > displayed nothing on the webform's design-view, yes? > > > > Based on my understanding, what you have encountered was the expected > > behavior. This is because by default, VS.NET will call the Control's Render > > method get the html displayed in design-view. And for Composite control, we > > used CreateChildControls to construct the control hierarchy rather than > > using Render method , so you'll get the empty(an arrow only) in > > design-view. > > > > If we do need to provide our customized Html View for our control at > > design-view, we can consider creating a custom control designer for our > > composite control. For example: > > > > we can apply a custom ControlDesigner class for a custom control like: > > > > [ Designer("CustomControls.Design.SimpleDesigner, CustomControls.Design")] > > public class Simple : WebControl { > > .................... > > } > > > > And we can override the "GetDesignTimeHtml() " method of the > > ControlDesigner class which is used to return the html code to display in > > IDE at design-time. For detailed description, you can refer to the > > following MSDN document: > > > > #Implementing a Simple Web Forms Control Designer > > http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmldesignersample > > .asp?frame=true > > > > Hope helps. Thanks, > > > > Steven Cheng > > Microsoft Online Support > > > > Get Secure! www.microsoft.com/security > > (This posting is provided "AS IS", with no warranties, and confers no > > rights.) > > > > You're welcome Spencer,
Thanks again for using MSDN newsgroup. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Please...Expert needed.
Click checkbox's label - javascript onclick gets called twice Changing the document.title from a user control Problem with FindControl Validation not working in paging Handling Events for Dynamically Created Controls File uploaded to server....How can I delete it? Checkbox within a datalist fill dropdown list thru dataset anyone who has used the FreeTextBox ? |
|||||||||||||||||||||||