473,738 Members | 4,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript __doPostBack() problem in IE

3 New Member
Hello, I have an address form which has a select box with countries and another select box with provinces.

When I select a certain country I cause a postback by using javascript __doPostBack function. I also have a submit button.

It works perfectly in both firefox and IE when I click on selectbox and select a country - it posts back and then on page load I populate the provinces based on the country just selected.

- EXCEPT: when I click on the select in IE, then select a country BUT I don't click on it, I hit enter to select that country.

This causes IE to actually submit the form as if I had clicked the submit button, which is NOT what I want.

Now if i change the type of the button to "button" instead of "submit", it doesn't behave that way, but then the user can't submit by hitting Enter.

I'm sure someone has come across this problem.
Is there a workaround for this?
Any idea on how to fix this?
Apr 26 '07 #1
3 4646
Frinavale
9,735 Recognized Expert Moderator Expert
Hello, I have an address form which has a select box with countries and another select box with provinces.

When I select a certain country I cause a postback by using javascript __doPostBack function. I also have a submit button.

It works perfectly in both firefox and IE when I click on selectbox and select a country - it posts back and then on page load I populate the provinces based on the country just selected.

- EXCEPT: when I click on the select in IE, then select a country BUT I don't click on it, I hit enter to select that country.

This causes IE to actually submit the form as if I had clicked the submit button, which is NOT what I want.

Now if i change the type of the button to "button" instead of "submit", it doesn't behave that way, but then the user can't submit by hitting Enter.

I'm sure someone has come across this problem.
Is there a workaround for this?
Any idea on how to fix this?

Hi Rizzy!

You could use a little bit of JavaScript to trap the event when the enter key is pressed

-Frinny
Apr 27 '07 #2
rizzy
3 New Member
thanks Frinny,

but it's too late by the time it gets to catchKeyPress() . The postback happens before this. And I forgot mention that this only happens with select boxes that have __doPostBack(ev entarget,eventa rg) tied to their onchange event. Maybe IE mixes up the eventtarget somehow or something. I don't know how i'm gonna fix this.
Apr 30 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
thanks Frinny,

but it's too late by the time it gets to catchKeyPress() . The postback happens before this. And I forgot mention that this only happens with select boxes that have __doPostBack(ev entarget,eventa rg) tied to their onchange event. Maybe IE mixes up the eventtarget somehow or something. I don't know how i'm gonna fix this.
Hi Rizzy,

Maybe try using a button since this solution works. Then simply write some JavaScript function that catches the key up event for ever element on the form and checks which form element this event happened for. Compare this value to the select boxes and if it matches do not the submit since its going to post back anyways. Otherwise submit the form.

I hope this helps you!
Good luck,

-Frinny
May 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3403
by: Juan Jose Costello Levien | last post by:
Hello, My name is Juan. I am new to the forum. Here I leave you a problem to see if you can help me. General Description I am developing an application in Visual Basic 6.
2
341
by: john | last post by:
I would like to do some client side stuff whenever my page is posting back. My page has a lot of different buttons and links that will cause a postback. I would rather not have to put something in each of their "onclick" functions. I would rather have a global OnPostback function or something like that. I tried using the form's onsubmit function, but it only gets called when my buttons are clicked; it doesn't get called when a link gets...
1
2495
by: Adrian | last post by:
I appear to be losing ViewState information when calling the __doPostBack function. I am attempting to use the showModalDialog to load a new web page which confirms that a user wishes to save a query. The showModalDailog returns a value to the original page which is used as a parameter in __doPostback, in turn trapped by the Page_Load procedure and processed.
6
4502
by: Jim | last post by:
Group, How would I go about firing a JavaScript method from a C# method in the aspx code behind file? It seems as though this could not be done since JavaScript is executed from within the Web browser and C# is executed on the server. Thanks for your consideration, Jim
3
15503
by: lanem | last post by:
I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks.
0
1918
by: Steve Richter | last post by:
ok, I admit I dont know what I am doing ... When a user clicks on a <tr> in a <table> I want the page to be posted back to the server with info as to what row was clicked. <tr style="background-color:ffecd8" onmouseover="this.style.backgroundColor='#ffdcff';" onmouseout="this.style.backgroundColor='#ffecd8';" onclick="javascript:__doPostBack('row1')">
2
4374
by: The Crow | last post by:
i want to raise an event on the server with a javascript call on the client. i found a solution but i think its not so elegant. the solution is: i call __doPostBack("RefreshPage", ""); from javascript and check in the Page_Load routine : bool refreshPage = Request.Form == "RefreshPage"; i could do it with __doPostBack("", "RefreshPage"); and == "RefreshPage" i could also add a hidden input control to the form, and set its value to
14
25634
by: Rich | last post by:
I am converting my enterprise solution from VS 2003 (.NET v1.1.4322) to VS 2005 (.NET v2.0.50727). The entire solution uses serveral technologies - Windows Server 2003 (AD, SQL Server 2000, IIS, ASP.NET, ASP.NET Mobile) Windows Mobile 2003 (Pocket IE) I have completed a portion of the conversion (ASP.NET Mobile pages for PIE, and some of the ASP.NET-bases web services), and while testing I have a runtime error that did not exist in the...
0
2274
by: codeshelp | last post by:
I have a gridview that has a ButtonField(Insert) that calls a detailsview which allows you to insert data to the gridview. The postback for this buttonField is: "javascript:__doPostBack('ctl00$POPAContentPlaceHolder$grdRemarks','Insert$0')", which takes me to the details view and were I click on a 'New' link with it's postback: "javascript:__doPostBack('ctl00$POPAContentPlaceHolder$grdRemarks$ctl01$DetailsView2','New$0')" How can I call...
7
88027
by: pardesiya | last post by:
Friends, I need to write a javascript function (which will be called on clicking a button) to return the currently selected item from a drop- down list whose rendered html is below. <select name="ddlQuery" onchange="javascript:setTimeout('__doPostBack(\'ddlQuery\',\'\')', 0)" id="ddlQuery" style="width:273px;"> <option value="Munich">Munich</option>
0
8788
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6751
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.