Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 13th, 2004, 01:02 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can dropdownlist OnFocus call a server-side method

Hi everybody. I'm trying to update the contents of a dropdownlist whenever it gains focus. Unfortunately, it seems the OnFocus event can only execute client-side code. Is it possible for this event to call a method in the codebehind?

There's probably even a better way to do this. All I really want to do is update the control after a popup window is closed.

Thanks for reading,
Jeff
  #2 (permalink)  
Old July 14th, 2004, 04:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I believe there was discussion of this on this forurm a while ago. If you search the archive, I'm sure you could find it.

I'm sorry but I forget what the result was. I believe you can't do it in the code behind but I don't want to lead you astray.

Brian
  #3 (permalink)  
Old July 14th, 2004, 08:52 PM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

This would mean a return trip to the server every time a user clicked on the control, even if they did not want to change it.
I don't think this would be a very good experience for the user.

Tell us more about the purpose of this, what data is changing to require the new data in the dropdown list.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
  #4 (permalink)  
Old July 14th, 2004, 09:00 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

The result of coding like this would be like Rod said, and a good example is the Automatic Refresh box at the top of the Active Topics page.

You would also have to reset the box to the selection the user made every time they select something else, along with whatever you want to have it do.

So, what is it you are trying to accomplish?

Snib

<><
  #5 (permalink)  
Old July 15th, 2004, 12:55 PM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the replies. The dropdownlist contains a list of files in the user's directory. A link on the page pops up a window that allows the user to upload files. Ideally I would like the dropdownlist to repopulate only when this popup window is closed.

Quote:
quote:Originally posted by rodmcleay
 This would mean a return trip to the server every time a user clicked on the control, even if they did not want to change it.
I don't think this would be a very good experience for the user.

Tell us more about the purpose of this, what data is changing to require the new data in the dropdown list.
  #6 (permalink)  
Old July 18th, 2004, 03:21 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, well this is much easier. The popup window could call the window it was launched from (window.opener) and call that window's form and submit it, basically performing a postback. Off the top of my head I think it would be something like this:

window.opener.document.forms[0].submit();

The trick then is getting the posted back form to repopulate the DDL. If the DDL is being filled only on "Not IsPostBack" then you need something to trigger a reload. Of course, you could always just load the DDL list every time the page loads (not as efficient however).

How are you populating the DDL with the user's files? Is this a user directory on the web server?
  #7 (permalink)  
Old July 19th, 2004, 11:50 AM
Registered User
 
Join Date: Jul 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Perfect, just what I needed.

It is a user dir on the server. I'm populating the control in the DDL's OnLoad with this code (C#):

Quote:
quote:try
{
    DirectoryInfo logoDir = new DirectoryInfo(logoRoot + userDir);
    LogoSelector.Items.Clear();
    LogoSelector.Items.Add(" ");

    foreach ( FileSystemInfo fsInfo in logoDir.GetFileSystemInfos() )
    {
        try
        {
            if ( !((File.GetAttributes(fsInfo.FullName) & FileAttributes.Directory) == FileAttributes.Directory) )
            {
                // It must be a file
                FileInfo fiLogo = (FileInfo)fsInfo;
                LogoSelector.Items.Add(fiLogo.Name.ToString());
            }
        }
        catch
        {
            // Skip this one and try the next...
        }
    }
    foreach ( ListItem li in LogoSelector.Items )
        li.Selected = li.Value.ToString() == graphic1.Text ? true : false;
    . . .
The method only fires once on page load and once when the popup is closed, so it should be fine. Thanks for the help!

Jeff
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Converting Client-side to Server-side Code kwilliams ASP.NET 2.0 Professional 1 November 21st, 2007 05:25 PM
DropDownList in side the DetailsView ndc550 ASP.NET 2.0 Basics 0 October 19th, 2006 05:10 PM
Firing server side events at client side codes mehdi62b ASP.NET 1.0 and 1.1 Basics 6 May 18th, 2005 09:11 AM
sharing a server-side variable with client-side pigtail Javascript How-To 6 November 4th, 2004 02:01 AM
Accessing Server Side Data on Client Side steve456 Classic ASP Professional 3 October 15th, 2003 02:33 PM



All times are GMT -4. The time now is 09:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.