.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 22nd, 2009, 01:40 AM
nigege nigege is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 19 nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 6 m 49 sec
Reputation Power: 0
VBScript - Discussion - Listbox_SelectedIndexChanged event no effects

hi all,

i'm using asp.net with a listbox for user to do selection for sqlQuery, now i met a problem that i want select an item from the list and if the item is contains "SUB" in string then i want visible another listbox in vb code lstbox_SelectedIndexChanged. but when i debugging, i select the list box item but no effect to the selectedIndexChanged event, so i cant make my another listbox appear if met my condition. if i enable "AutoPostBack" then the item i select will be refreshed. so how can i do in this situation?

thanks for help in advanced

Reply With Quote
  #2  
Old October 22nd, 2009, 07:18 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
you have two common options: either put your drop down inside UpdatePanel
then using AutoPostBack won't reload the whole page, or more simple but less
elegant solution is using client side code to show the other list box.

let me know your decision, can't help with UpdatePanel since I never personally
work with these but if you choose client side solution I can give some code.

Reply With Quote
  #3  
Old October 22nd, 2009, 08:50 PM
nigege nigege is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 19 nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 6 m 49 sec
Reputation Power: 0
i am using listbox but dun know have same action as dropdown or not. regards the updatePanel, is it a simple panel with name UpdatePanel or there a special UpdatePanel? i prefer to use clientside code, that will be faster right? so can u guide me some code?

Reply With Quote
  #4  
Old October 23rd, 2009, 07:43 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
Quote:
Originally Posted by nigege
i am using listbox but dun know have same action as dropdown or not. regards the updatePanel, is it a simple panel with name UpdatePanel or there a special UpdatePanel? i prefer to use clientside code, that will be faster right? so can u guide me some code?
OK.
You'll have to pass the Client ID of the listbox you wish to hide to the
client side code, then override the "onchange" of the first listbox:
Code:
protected void Page_Load(object sender, EventArgs e)
{
   Page.ClientScript.RegisterClientScriptBlock( Page.GetType(), "listbox_id", string.Format("var _listBoxId = '{0}'; ", OtherListBox.ClientID), true );
   lstBox.Attributes["onchange"] = "ListBoxChanged(this);";
}

(this is C#, it should be simple to translate to VB.NET - replace OtherListBox with
the name of the drop down list you wish to hide)

Having this, add this client side code to your .aspx page to make it work:
Code:
<script type="text/javascript">
function ListBoxChanged(oListbox)
{
	var otherListbox = document.getElementById(_listBoxId);
	if (oListbox.value.indexOf("SUB") >= 0)
	{
		otherListbox.style.display = "none";
	}
	else
	{
		otherListbox.style.display = "";
	}
}	
</script>


That's it... please read the code and try to understand how it works, I'm
sure if you spend some time you'll figure the logic behind it and it will help
you solve problems that might occur with the code.

Let me know how it goes!
Comments on this post
Rictor agrees: Wish I had your knowledge in making client side code work with server controls.

Last edited by Shadow Wizard : October 23rd, 2009 at 07:50 AM.

Reply With Quote
  #5  
Old November 4th, 2009, 04:37 AM
nigege nigege is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 19 nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 6 m 49 sec
Reputation Power: 0
hi, thanks reply.

when i apply to the code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Page.ClientScript.RegisterClientScriptBlock(Page.G etType(), "listbox_id", String.Format("var _listBoxId = '{0}'; ", lstSubAcute.ClientID), True)
lstDiag.Attributes.Add("onchange", "ListBoxChanged(this);return false")

End Sub

where
lstDiag is the main listbox to decide show/hide second listbox
lstSubAcute is the second listbox to show/hide

but when i test run, the page all disappear. so i think i passing wrong thing to the codes. can suggest me??

Reply With Quote
  #6  
Old November 4th, 2009, 06:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
you probably have AutoPostBack set as True for your drop down.
Please change this to be False and changing the value won't
"make the page disappear", as you call it.

Reply With Quote
  #7  
Old November 4th, 2009, 08:17 PM
nigege nigege is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 19 nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 6 m 49 sec
Reputation Power: 0
hi, i have checked, sorry i too blur, accidentally set form visible to false.. hahah .. another things is, u mention the drop down is same as list box i mention?? thanks for help me to debug.
and now, the second listbox is showing directly, then i want to do like this. i have 3 items in 1st list box, when i select 3rd items then just show the second listbox, if i change to select 1 or 2 item, then second listbox is hide. how do code it in listbox selectionChanged?

from your code:
oListbox.value.indexOf("SUB") >= 0
indexOf("SUB") mean??
>=0 mean??

thanks

Reply With Quote
  #8  
Old November 5th, 2009, 02:56 AM
nigege nigege is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 19 nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 6 m 49 sec
Reputation Power: 0
Hi, thanks, is function already.

and i also understand the meaning that i ask in previous post.

it functions as what i want. and now i need to let the second listbox invisible at begining cos my 1st item in 1st listbox is to hide the second listbox. but i set 1st listbox.selectedIndex to 0 but it wont run the javascript to hide second listbox. then i try set visible of 2nd listbox to false at development, then error occur in javascript cos cant find the control(2nd listbox).

Any suggestion to this?? thanks "shadow" for helping

Reply With Quote
  #9  
Old November 5th, 2009, 05:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
glad you got it, well done.

to make the drop down initially hidden, add the code in bold to your .aspx code:
Code:
<asp:DropDownList id="lstSubAcute" runat="server" style="display: none;">

this will make your list hidden, and when the JS function will run, it will show it.

Reply With Quote
  #10  
Old November 8th, 2009, 09:42 PM
nigege nigege is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 19 nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level)nigege User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 6 m 49 sec
Reputation Power: 0
Thanks again for solve my current javascript problem.

but only a bit problem is in design way, the second box will go down new line automatically if i visible it, unless i give a few space after the second box then the second box will appear at the same line as design.

Thank Shadow Wizard~

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > VBScript - Discussion - Listbox_SelectedIndexChanged event no effects


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek