473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help .. Button does not function properly.

I hope someone can help me out. I am trying to create a simple page
with a drop down list that gives the user the ability to select which
url they would like to run. The url does call a javascript function
"openWin" that opens the browser to a specific size.

The problem is that everytime I select a value in the drop down list I
have to click the button twice to get the right url to open. The first
time always opens the wrong url.

Here's my code..
-------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Select Case DropDownList1.SelectedValue
Case "0"
Button1.Attributes.Add("language", "javascript")
Button1.Attributes.Add("onClick",
"openWin('http://www.microsoft.com');return true;")
Case "1"
Button1.Attributes.Add("language", "javascript")
Button1.Attributes.Add("onClick",
"openWin('http://www.yahoo.com');return true;")
End Select
End Sub

---------------------------------------------------------------

<form id="Form1" method="post" runat="server">
<asp:dropdownlist id="DropDownList1" style="Z-INDEX: 101; LEFT:
160px; POSITION: absolute; TOP: 40px"
runat="server" Width="208px">
<asp:ListItem Value="0"
Selected="True">microsoft.com</asp:ListItem>
<asp:ListItem Value="1">yahoo.com</asp:ListItem>
</asp:dropdownlist>
<asp:Button id="Button1" runat="server" Text="Button"
CausesValidation="False"></asp:Button>
</form>

-------------------------------------------------------------------

Nov 19 '05 #1
3 946
Chuck:

You may want to set the EnableViewState property of the dropdownlist to
false.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Chuck" <ch***@yeshcom.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I hope someone can help me out. I am trying to create a simple page
with a drop down list that gives the user the ability to select which
url they would like to run. The url does call a javascript function
"openWin" that opens the browser to a specific size.

The problem is that everytime I select a value in the drop down list I
have to click the button twice to get the right url to open. The first
time always opens the wrong url.

Here's my code..
-------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Select Case DropDownList1.SelectedValue
Case "0"
Button1.Attributes.Add("language", "javascript")
Button1.Attributes.Add("onClick",
"openWin('http://www.microsoft.com');return true;")
Case "1"
Button1.Attributes.Add("language", "javascript")
Button1.Attributes.Add("onClick",
"openWin('http://www.yahoo.com');return true;")
End Select
End Sub

---------------------------------------------------------------

<form id="Form1" method="post" runat="server">
<asp:dropdownlist id="DropDownList1" style="Z-INDEX: 101; LEFT:
160px; POSITION: absolute; TOP: 40px"
runat="server" Width="208px">
<asp:ListItem Value="0"
Selected="True">microsoft.com</asp:ListItem>
<asp:ListItem Value="1">yahoo.com</asp:ListItem>
</asp:dropdownlist>
<asp:Button id="Button1" runat="server" Text="Button"
CausesValidation="False"></asp:Button>
</form>

-------------------------------------------------------------------
Nov 19 '05 #2

"Chuck" <ch***@yeshcom.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I hope someone can help me out. I am trying to create a simple page
with a drop down list that gives the user the ability to select which
url they would like to run. The url does call a javascript function
"openWin" that opens the browser to a specific size.

The problem is that everytime I select a value in the drop down list I
have to click the button twice to get the right url to open. The first
time always opens the wrong url.

Here's my code..
-------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Select Case DropDownList1.SelectedValue
Case "0"
Button1.Attributes.Add("language", "javascript")
Button1.Attributes.Add("onClick",
"openWin('http://www.microsoft.com');return true;")
Case "1"
Button1.Attributes.Add("language", "javascript")
Button1.Attributes.Add("onClick",
"openWin('http://www.yahoo.com');return true;")
End Select
End Sub

---------------------------------------------------------------


It's quite obvious that it needs two clicks.
First click sets the button's attribute onClick="openWin('htt..')".
Second click activates this event.
Nov 19 '05 #3
Thanks for the respone, so how can make this work with one click.

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mike | last post by:
I've been trying for the past week to put a simple code together. I have done a LOT of searching, found scripts showing the functions I would like to use, however when I mix them it all goes wrong,...
1
by: Jenny | last post by:
Need urgent help for an unsolved problem. In our ASP web application, we creat a Back button and if user click on this button, it execute history.go(-1) to go back to the previous page. All our...
13
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
4
by: David Jia | last post by:
Hi, I have a problem in VS2003 and .Net 1.1 as below: I put a HTML submit button control and label it as "run @ server" My purpose is that when click this button, system will check the input...
25
by: crescent_au | last post by:
Hi all, I've written a login/logout code. It does what it's supposed to do but the problem is when I logout and press browser's back button (in Firefox), I get to the last login page. In IE,...
3
by: mcmahonb | last post by:
Hey people... I've been searching this forum for a few hours and even though this topic has been went over from many different angles; I cannot seem to figure out how to make things work on my...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
18
by: Axel Dahmen | last post by:
Hi, trying to submit an ASPX form using the key (using IE6) the page is not submitted in my web project. Trying to debug the pages' JavaScript code I noticed that there's some ASP.NET client...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.