is there a cleaner way to code this

R

rodchar

hey all,

please reference: http://pastebin.com/mef78b3d

As shown in the reference I am dynamically building my controls in my class.
I'd like to be able to attach javascript calls as attributes to each of my
controls if applies.

for example,
String varString = "alert('i'm a textbox')";
txt.attributes.add("onmouseover", varString);

now i know i can code this in each case statement but i was wondering if
there was a way to code this once and after the switch statement and do it on
whatever control is built?

thanks,
rodchar
 
O

oogity

sounds like somebody forgot her midol today


Peter Duniho said:
Please do not reference external web sites. Please _do_ post your code
with your message. Please _do_ make sure your code is a
concise-but-complete code sample. And please _do_ write a "Subject:"
field that is reasonably descriptive of the actual question at hand.


Does this mean you're writing a web application (i.e. using the Web.UI
namespace)? If so, you should be specific about that, as that's
definitely a "special case".


How does a switch/case statement come into it? Wouldn't it just be an
explicit part of the initialization of the original control?

Pete
 
J

Jeroen Mostert

oogity said:
sounds like somebody forgot her midol today
It's time for another Good Idea, Bad Idea.

Good Idea: making it easy and attractive for people to help you.
Bad Idea: insulting people who are willing to help you for criticizing.
 
R

rodchar

Yes, this is a web application. This code appears in my class that implements
ITemplate (InstantiateIn method) which is then loaded into my FormView
dynamically.
 
O

oogity

insulting ? it was just a comment critiquing a crappy attitude - I fail to
see how being helpful ( if indeed one is being helpful ) necessitates or
validates being needlesly critical.

as usual, I didn't see any 'help' whatsoever in that post - just the usual
ng copper routine.

.... don't scream at me for calling you a bitch, scream at yourself for
being one ...


how about a few more :

Bad Idea : discouraging people from seeking help by displaying an overly
critical & condescending attitude.

Bad Idea : clog the newgroups with useless bandwith wasting netiquette / 'in
my ng you do things my way' posts


sorry for wasting anyones bandwidth with this post.
 
J

Jeroen Mostert

oogity said:
insulting ? it was just a comment critiquing a crappy attitude - I fail to
see how being helpful ( if indeed one is being helpful ) necessitates or
validates being needlesly critical.
I agree, there's no point to being *needlessly* critical... Pointing out
things you might do to ensure more people will read and respond to your post
seems to be a good use of criticism to me, though.
as usual, I didn't see any 'help' whatsoever in that post - just the usual
ng copper routine.
What about the part where he asked follow-up questions? Seems proactive to me.
... don't scream at me for calling you a bitch, scream at yourself for
being one ...
I'm rubber, you're glue! And so on till its our bedtime.
how about a few more :

Bad Idea : discouraging people from seeking help by displaying an overly
critical & condescending attitude.

Bad Idea : clog the newgroups with useless bandwith wasting netiquette / 'in
my ng you do things my way' posts
I've heard this tune before, and I'm pretty sure the "that's
helpful"/"that's just mean" divide is a matter of degree and opinion. Let's
call it a day.
sorry for wasting anyones bandwidth with this post.
I'll reimburse anyone who feels cheated.
 
B

Ben Voigt [C++ MVP]

Bad Idea : discouraging people from seeking help by displaying an
overly critical & condescending attitude.

Peter's post wasn't condescending. He offered constructive advice on how to
get more people to help.

For example, because OE's support for external links is broken on my
workstation, I haven't checked the code in question.

If rodchar took Peter's advice he'd get more help.
Bad Idea : clog the newgroups with useless bandwith wasting
netiquette / 'in my ng you do things my way' posts

There was nothing possessive, just solid information on "Hhow to post a
question that gets answered".
 
R

rodchar

hey all,
sorry for the trouble...can someone please see my previous post in response
to Peter. did i supply enough information for additional help?

please advise,
rod.
 
M

Marc Gravell

It sounds like you just want something like:

WebControl cont;
switch(something) {
case 1:
SpecificControl spec = new SpecificControl();
spec.SpecificProperty = "blah";
// etc
cont = spec;
break;
case 2:
// etc;
cont = spec;
break;
}
cont.SomeBaseProperty = "foo";
cont.SetSomething("bar");

?

Marc
 

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

Top