Processing a lot of web controls

  • Thread starter Thread starter Bogdan Zamfir
  • Start date Start date
B

Bogdan Zamfir

Hi,

I want to enable / disable several controls on a page based on a condition
in application.

But there are several other controls on the page don't want to enable /
disable together with the others.

In desktop applications, I used a control's property who was not used, like
Comment or Tag.

I loop through all controls, and based on TAG's or Comment's value, I make
them Enable / Disable.

But this doesn't seems to be such property for web controls. How can I
accomplish this?

I see there is a Attribute collection (in help it sais it is used for
several attributes not covered by properties, for rendering purpose)

I want to use this, to add a new attribute for this, but I cannot do this at
design time (when I need to "mark" what controls to process).

I'll appreciate any suggestions on this issue.

Thank you

Bogdan
 
Hi Bogdan,
use the code below
bool x = true;

System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append("<script language=javascript>") ;

if (x)
sb.Append("document.forms(0).TextBox2.disabled=true;");



sb.Append("</script>");

if (!(IsStartupScriptRegistered("Able")))

RegisterStartupScript("Able", sb.ToString());
 
Hi Bogdan,
use the code below
bool x = true;

System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append("<script language=javascript>") ;

if (x)
sb.Append("document.forms(0).TextBox2.disabled=true;");



sb.Append("</script>");

if (!(IsStartupScriptRegistered("Able")))

RegisterStartupScript("Able", sb.ToString());
 
Hi,

Thank you for your answer.
But unfortunately I don't need a client-side script to disable controls. I
can do this on server side.
I want to be able to "mark" some controls somehow (in windows desktop
application I usually use TAG or Comment properties, which are not used by
the compiler)

Is there any way to do this?

Thank you

Bogdan
 
Bogdan Zamfir said:
Hi,

Thank you for your answer.
But unfortunately I don't need a client-side script to disable controls. I
can do this on server side.
I want to be able to "mark" some controls somehow (in windows desktop
application I usually use TAG or Comment properties, which are not used by
the compiler)

Is there any way to do this?

No. There is no "Tag" property or anything like it.

What I usually do is either manually create my own list:

Control[] controlsToDisable = new Control[]{
txtName,
txtEmail,
...,
lstCountry};

or I put all the controls together into a single Panel or PlaceHolder
control and iterate through Panel.Controls or PlaceHolder.Controls.
 
Back
Top