Processing a lot of web controls

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
 
R

Rohit Kukreti

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());
 
R

Rohit Kukreti

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());
 
B

Bogdan Zamfir

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
 
J

John Saunders

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.
 

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

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top