make Serializable or create custom TypeConverter ?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default make Serializable or create custom TypeConverter ?

    Hi,

    I try to assign a variable of type WebControls.Button to ViewState as
    follows

    ViewState["m_ballSelected"] = m_ballSelected;

    but get an error -->

    "The type 'System.Web.UI.WebControls.Button' must be marked as Serializable
    or have a TypeConverter other than ReferenceConverter to be put in
    viewstate."

    How do I mark this intrinsic-control as Serializable ?
    or else ...
    I guess I have to create a custom TypeConverter for my Button then ?
    How do I do that ?
    any code samples someone can recommend me ?

    thanks

    chris


    Christian Guest

  2. Similar Questions and Discussions

    1. TypeConverter and Generics
      Hi, As far as I can tell, it is not possible to use the TypeConverter infrastructure with generic types. Say you have this type: public struct...
    2. CAS prevents call to ConvertTo used by custom TypeConverter
      Hi, I have a web control, that has a property (a collection of strings) with it's own editor and typeconverter. The problem is that the type...
    3. TypeConverter
      Hi Everyone, I have a custom dropdownlist control with a LoadItemsFrom property. I created a TypeConverter for this property that displays a list...
    4. TypeConverter HELP Needed!
      Ok, I have a property called ControlType. The property is of type 'Type'. It stores just the type of control a user selected. I am really confused...
    5. [Q]how to make webservice defined type to have [serializable] attribute when generating the wsdl file?
      I define a type in web services code that is used by webmethods as parameters. This type with its public data members is included in the generated...
  3. #2

    Default make Serializable or create custom TypeConverter ?

    Just add EnableViewState="True" as an attribute to the
    button in the aspx file.

    HTH,
    Gaz

    >-----Original Message-----
    >Hi,
    >
    >I try to assign a variable of type WebControls.Button to
    ViewState as
    >follows
    >
    > ViewState["m_ballSelected"] = m_ballSelected;
    >
    >but get an error -->
    >
    >"The type 'System.Web.UI.WebControls.Button' must be
    marked as Serializable
    >or have a TypeConverter other than ReferenceConverter to
    be put in
    >viewstate."
    >
    >How do I mark this intrinsic-control as Serializable ?
    >or else ...
    >I guess I have to create a custom TypeConverter for my
    Button then ?
    >How do I do that ?
    >any code samples someone can recommend me ?
    >
    >thanks
    >
    >chris
    >
    >
    >.
    >
    Gary Varga Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139