Error Message - "Method may only be called on a Type for which Type.IsGenericParameter is true" - while making use of a custom control

Hi everybody,

In my project i am making use of a custom control CC1 which was working perfectly fine in the .NET 1.1 framework... I exported the same to .NET2.0 and now it is not even generating an event!!!

After much probing I found this particular message - "Method may only be called on a Type for which Type.IsGenericParameter is true." - Is this in any way related to the error in the functionality (error in event creation) i am facing??? Can I manually set any control to a generic type? How can I do that??

Can somebody please help me out in this matter.  

Hoping a reply from any of you at the earliest.

Thanks.

0
rtg2006
2/9/2007 11:38:24 AM
asp.net.custom-server-controls 3498 articles. 0 followers. Follow

5 Replies
3179 Views

Similar Articles

[PageSpeed] 39

U can't define the class for your custom control to be of generic type
Then the error tells you about parameter of method   Which method?

Can you post here or Email me your code?   
Guennadi Vanine - Gennady Vanin - Геннадий Ванин
0
guenavan
2/9/2007 12:25:17 PM

Hi Guenavan,

Can you possibly list out the reasons why events are not getting generated in this particular situation. Are there any changes to be made to the code of a custom control when we migrate it from 1.1 to 2.0 ??? Or are there any specific attribute to be set in 2.0 which was not required previously???

Let me again mention this - it was working as expected in 1.1... and now in 2.0 framework the event itself is not getting generated...

thanks...
 

 

 

0
rtg2006
2/9/2007 12:44:40 PM
what situation? You did not explain anything specifically
Guennadi Vanine - Gennady Vanin - Геннадий Ванин
0
guenavan
2/9/2007 1:02:50 PM

The custom control being used has the following model - It has a table and each cell of this table contains a button. Something like this,

public class TableControl : WebControl
{
       AddingChildControls()
      {

         Table1 T = new Table1();       
         this.Controls.add(Table1);       
      }
}


internal class Table1 :Table
{
        public delegate void DecisionTableChangedHandler(TableRow[] newTable);
        public event DecisionTableChangedHandler DecisionTableChanged;
        // code...

        TableRow row = new TableRow();

         Cell1 c = new Cell1();
         Button1 B = new Button1();
         c.Contols.Add(B);

         row.Cells.Add(c);
        this.Rows.Add(row);

internal class Button1 : WebControl
{
        ImageButton btn1 = new ImageButton();
        public event EventHandler Click;
        // Design properties...
}

internal class Cell1:TableCell
{
        public delegate void DTCellEventHandler (Cell cell, DTEvent e) ;
        public event DTCellEventHandler CellEvent;
       // code ...
}

Well, all I want to know is why events are not being raised in the custom control which I have been using. Is it in any way related to the message i posted earlier?? - "Method may only be called on a Type for which Type.IsGenericParameter is true" - or is it not?

I would also be very much pleased if anybody can just suggest the reasons for why the events are not getting raised...

Hope this is clear enough Guenavan... :)

thanks.

0
rtg2006
2/12/2007 5:29:53 AM
How did you get the message "Method may only be called on a Type for which Type.IsGenericParameter is true"? Was an exception thrown, and if there was, can you post the call stack?
0
jbresler
2/14/2007 9:18:24 PM
Reply:

Similar Artilces:

Using Web Service Result of Custom Type for Custom Control
 Hi there, this is my first question on the ASP.NET forums! Yay!OK, here is the problem I am having (also blogged here: http://cantgrokwontgrok.blogspot.com/2008/06/problem-aspnet-custom-controls-custom.html)I have a web service, which queries some data and returns the result as a SerialisableList.This serialisable list is then used on various pages as a data source, presented in different ways.I need to do another page, but would like to encapsulate the logic into a control (since its going to be pretty complex). I have started a control, and added the property of the type Serialisable...

Custom controls called from inside other custom controls???
I'm fairly new to writing controls in ASP.NET so, forgive the I am trying to create a base page class which will call 3 custom controls. This base page class will span across multiple projects hence the reason I am not creating user controls. These 3 custom controls are: 1. TopNav-uses render method to display an HTML table with graphics for top navigation. 2. ImagePairs-uses prerender method to add javascript code to manage what graphic is displayed in TopNav onMouseOver and onMouseOut 3. MgrHeader-uses render method to display an HTML table with s...

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). http://blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

Custom Control: Calling a function on calling page FROM a custom control ? help !!
I have a custom control placed on many pages, to make things simple, basically what I want to do is Call a function on the calling page from the custom control ieAnyone have any ideas, simple solution would be good !!  This is the code I have myControl.ascx.vbPublic Partial Class myControl    Inherits System.Web.UI.UserControl    Protected Sub testButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testButton.Click        'call save function on PersonalDetails.aspx.vb  &...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingcompositecontrols.asp Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

Get control type for custom control?
For basic controls (text boxes, etc.) it's relatively easy to test for their type.  but how do I reliably test for the type of a custom control?For example, I have a custom control called MyControl and would like to do something similar to this: If Me.FindControl(strControlToFind).GetType = MyControl.GetType Then ... Obviously this example doesn't work, as there is no GetType for MyControl defined.  Can I setup a Type for my control?  Or is there an easier way?  You could always try:If (TypeOf (Me.FindControl(strControlToFind)) Is MyControl) then ...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. http://forums.asp.net/p/1397433/3010100.aspx#3010100 I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal asp.net page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer asp.net sites and/or SharePoint sites why don't you just create Web Par...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Using a server control in the rendering a custom control
Hi. I have a custom control that overrides the Render method to draw itself.  Is it possible to use a server control (asp:Image, wwHoverPanel, etc.) inside such a custom control or would I have to rewrite my custom control as a composite control? I'd like to do something something like:protected override void Render(HtmlTextWriter w) { w.RenderBeginTag(HtmlTextWriterTag.Table); w.RenderBeginTag(HtmlTextWriterTag.Tr) w.RenderBeginTag(HtmlTextWriterTag.Td) // somehow place asp:Label here w.RenderEndTag(); // column w.RenderEndTag(); // row ...

Custom control with strongly typed custom collection
I have written a custom web control which has a property called Items. This property is a strongly typed collection (List<MyType>) but there are two annoying problems that don't go away and so the control does not work well in design time (only at runtime):  For background see http://forums.asp.net/t/1128264.aspx When in design mode I can get the collection editor to create items as it knows what the type is. Then when you are done it creates some HTML markup inside the tags of the control and that is where it goes wrong because next time you come back to design mode the con...

Using a user control in a custom server control.
I've created a custom server control and am trying to add a user control to the rendering of the server control.  Is this possible?  If so, hints as to how this is done would be GREATLY appreciated!  Thanks in advance for considering an answer to this question. Wendi Use the LoadControl method. For example:   Controls.Add(LoadControl("~/controls/login.ascx"))Steven BeyRecursion: see Recursion My server control renders a table with x number of rows.  I want to add a user control to each row of the table, last column.  I do not know how ...

Use Renderchildren method in Webusercontrol Error:Control of type 'TextBox' must be placed inside a form tag with runat=server.
I have create a form Webfor1.aspx which has following code: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" EnableEventValidation ="false" Inherits="WebApplication1.WebForm1" %> <%@ Register Src="WebUserControl1.ascx" TagName="WebUserControl1" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <...

Custom Control to Custom Control communication using event delegate mech.
I have a custom control “AddressPicker” that displays dynamic address information of a user. BY dynamic I mean based on the database call it checks how may addresses a user has and it displays it. There is a “Use this Address” button at the bottom of each address information which is generated dynamically too as a part of CreateChildControl. If a user click on this button I need to pass this information to another custom control namely “AddressConsumer” which in turn uses this information for further processing.My Controls are inherited WebCOntrol,INamingContainer I am using the event deleg...

how to have both server controls and html controls rendered in a custom control?
I have a custom control in which there is an html text box.when you click on it , a div containing a table is appeared and according to what you select in that table a text is set to the text box. It works fine but the problem is: as the text box is an html element it doesn't have viewstate and when a post back occures in the page its value disappeares.I tried a hidden field to keep its value.again there is another problem : I put this custom control in a usercontrol and put the usercontrol in a multiview and by clicking on a button this view is selected and by clicking another bu...

Limiting the type of child controls a custom control can have
 How does one do this? I'm looking to create a web control that functions similar to the DropDownList control, in that it would only allow certain types of child controls inside of it(ex: DropDownList only allows ListItems in it). Am I missing something glaringly obvious about this problem? I can't seem to find any information on how to do it. Those aren't child controls.  It is a custom syntax for setting the Property "Items" of the the drop down list.The inner  contents of a control can either be properites or custom controls.  For instance...

Web resources about - Error Message - "Method may only be called on a Type for which Type.IsGenericParameter is true" - while making use of a custom control - asp.net.custom-server-controls

Resources last updated: 1/19/2016 3:35:14 AM