.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, 12: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 8 m 28 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, 06:18 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 29,260 Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 2 Days 30 m 22 sec
Reputation Power: 2509
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, 07: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 8 m 28 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, 06:43 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 29,260 Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 2 Days 30 m 22 sec
Reputation Power: 2509
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 06:50 AM.

Reply With Quote
  #5  
Old November 4th, 2009, 03: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 8 m 28 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, 05:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 29,260 Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 2 Days 30 m 22 sec
Reputation Power: 2509
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, 07: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 8 m 28 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, 01: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 8 m 28 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, 04:20 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 29,260 Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 23rd Grade (Above 100000 Reputation Level)  Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2Folding Points: 587027 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 2 Days 30 m 22 sec
Reputation Power: 2509
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, 08: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 8 m 28 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!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

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





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