RE POSTING Problem with a text box with custom properties in the IDE !!!HELP any MVP!!

S

Sanjay Pais

Sanjay Pais said:
This is an extension of an earlier post
I have created a custom text box and compiled it and dropped it into my
toolbox. However when I change the value of my custom property in design
mode and switch between design mode to page source and back to design mode
i
am unable to retrieve the property value I set. Also the property setting
in
the html page is lost.

Thsi is the error I get
**********************************
System.Reflection.TargetInvocatonException: Property accessor
'ApplySecurity' on object 'ATextBox2' threw the follwoing exception:
Object
reference not set to an instance of an object~
System.NullReferenceException
--inner stack trace--
System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.GetPropertyValueCore(Object
target)
System.Windows.Forms.PropertyGridInternal.PropertyDescriptorGridEntry.get_PropertyValue()

**********************************
Mu source code is
I have added a custom property called ApplySecurity to the html

my custom text box in the page html source of the designer looks like this
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="AEPFieldDisco.aspx.cs" Inherits="AEPSampleWPD" %>

<%@ Register Assembly="AWebControlLibrary" Namespace="AEPortal"
TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<cc1:ATextBox ID="ATextBox1" runat="server"
ApplySecurity="True"></cc1:ATextBox>

</form>

</body>

</html>

*********************************************

My text box in the dll has this code

using System;

using System.Collections.Generic;

using System.Text;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.ComponentModel;

using System.Drawing;

namespace AEPortal

{

[ToolboxData("<{0}:ATextBox runat=server
ApplySecurity=True></{0}:ATextBox>")]

public class ATextBox : System.Web.UI.WebControls.TextBox

{

[Bindable(true),

Category("Misc"),

DefaultValue("False")]

string strApplySecurity = null;

public string ApplySecurity

{


get

{

try

{

strApplySecurity = this.Attributes["ApplySecurity"].ToString();

}

catch

{

}

if (strApplySecurity == null)

{

this.Attributes.Add("ApplySecurity", "False");

return "False";

}

else

{

return strApplySecurity;

}

}

set

{

string strTestValue=null;

try

{

strTestValue = this.Attributes["ApplySecurity"].ToString();

}

catch { }

if (strTestValue == null)

{

this.Attributes.Add("ApplySecurity", value);

}

else

{

this.Attributes["ApplySecurity"] = value;

}

}


}

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top