Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Another "widget" question...

Author  Topic 

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-01-07 : 10:23:03
I thought about continuing this thread:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=43656

But it seems to have been forgotten.

I have a web page with 12-15 dropdown lists, each with the same datasource. Instead of having 15 copies of the same HTML for each list I'd like to recycle a single dropdown for each controls. I've done this before in ASP and JavaScript but if I can do this in .Net I'd like to, to keep it consistent with the rest of the page. Unfortunately I don't see a way to do it without client-side code; not that I mind client-side code, except it does not work and play well with server-side .Net code.

Any pointers? Or should I just live with a large page size? (this page isn't so bad, but others I'd like to do will get VERY big without something like this)

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-01-07 : 10:51:09
Rob,
I'm not sure I 100% understand the question, but have you tried using a Web User Control? Create one Control that has the HTML and dropdown you need, and add that control multiple times to the ASPX page.

Does that make sense, or does that not solve the problem?
Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

jhermiz

3564 Posts

Posted - 2005-01-07 : 13:09:49
I'm not sure why you have 15 of the same combo boxes ???

By the way if its the same datasource you can write one specific function and reuse it across all of those combo boxes.
Is that what you are looking for is a generic function to fill these or do you have that ?



Keeping the web experience alive -- [url]http://www.web-impulse.com[/url]


Additional resources for you...
  • SQL Reporting Services -
  • [url]http://www.ondotnet.com/pub/a/dotnet/2004/11/01/reportingsvcs.html[/url]
  • ASP.net - [url]http://www.asp.net[/url]

  • COM - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/componentobjectmodelanchor.asp
  • color="purple">Tree Reports in RS - [url]http://odetocode.com/Articles/95.aspx[/url]
  • Connecting to SQL via Java -- [url]http://www.akadia.com/services/sqlsrv_jdbc.html[/url]
  • C# -- [url]http://msdn.microsoft.com/vcsharp/[/url]

  • Go to Top of Page

    MichaelP
    Jedi Yak

    2489 Posts

    Posted - 2005-01-07 : 14:03:18
    Or maybe you create one copy of the control in code, and do a target.controls.add(myDropDownInstance)

    Michael



    <Yoda>Use the Search page you must. Find the answer you will.</Yoda>
    Go to Top of Page

    robvolk
    Most Valuable Yak

    15732 Posts

    Posted - 2005-01-07 : 20:27:33
    I thought about using a user control, but my goal is to not have multiple copies of the same HTML source in the rendered web page. A user control will still repeat the same code for each dropdown.

    Why are there 15? They store revenue codes for various service charges we charge to our clients. The table could have been normalized so that they are stored on 15 different rows, but it's not worth redesigning the entire database over this one issue.

    As I said, it's not a big deal for this page to use the extra space; still, I'd prefer to limit the amount of crap HTML .Net likes to render. I've already turned off viewstate for now and dread having to turn it on when I add some new features that need it. THAT'S the real reason I'm trying to recycle the dropdown, because with the extra HTML AND viewstate the page will probably double in size from what it would be with a single dropdown.

    And don't get me started on the 1200+ option dropdowns we have on ANOTHER web page...that puppy renders out to 500+K worth of HTML.
    Go to Top of Page

    jsmith8858
    Dr. Cross Join

    7423 Posts

    Posted - 2005-01-07 : 20:51:00
    I think you have no choice but to use client-side, non-ASP.NET javascript. i imagine that for something like this, you'd do it the same as you did in ASP. It's really a HTML/Javascript issue, I suppose, rather than an ASP.NET thing ....

    Actually, though, you could write an ASP.NET user control that has the client-side javascript embedded with it, that control could take a parameter that indicates which element on the page to copy its drop-down list from when it gets the focus (or when it loads the page or whenever). Then the server-side control can render the HTML with the client side script as well.


    - Jeff
    Go to Top of Page

    robvolk
    Most Valuable Yak

    15732 Posts

    Posted - 2005-01-07 : 21:07:39
    Thanks Jeff, I'm thinking that might work. Unfortunately it pretty much means I don't get any benefits from .Net if I go that route.

    It's really a shame how MS utterly ignored the capabilities of client-side coding and put all of the good stuff into the server side, and you need to post back to get it. Viewstate is a shitty hack anyway, but it would've been SIMPLE to make it a little smarter to effectively handle a control like I need.

    All I can say is: thank god for the Cache class! At least they did that one right.
    Go to Top of Page
       

    - Advertisement -