 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 13th, 2004, 01:02 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 14th, 2004, 04:56 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

July 14th, 2004, 08:52 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
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.
======================================
|
|

July 14th, 2004, 09:00 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
<><
|
|

July 15th, 2004, 12:55 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|
|

July 18th, 2004, 03:21 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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?
|
|

July 19th, 2004, 11:50 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |