473,324 Members | 2,248 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,324 software developers and data experts.

Post back using javascript

I had a listbox, whose autoPostBAck property was set to true. So. if
I was clicking on any item for the first time, it caused a successful
post-back. However, if i clicked on the item subsequently, no post-
back occured (because the index of the selected item did not change,
hence the click event was not captured).

So, to capture the click event everytime, i added a _dopostback
function in javascript code. This made post-back possible for
subsequent clicks on the same list-item.
But i get a problem because of this. Now when I click on a list-item
first time, post-back occurs twice:
-- Once because of javascript function (_dopostback)
-- Secondly, because of autoPostBack property of list-box set to
true.
However, on second click, there occurs only one post-back because of
javascript only. Thats wat I require. Wat i dont require is two post-
backs on first click!!!
Pls tell me how do I prevent javascript function from working on
first
click of the list-item???

May 24 '07 #1
2 6790
On May 24, 6:51 am, Garg <shivaniga...@gmail.comwrote:
I had a listbox, whose autoPostBAck property was set to true. So. if
I was clicking on any item for the first time, it caused a successful
post-back. However, if i clicked on the item subsequently, no post-
back occured (because the index of the selected item did not change,
hence the click event was not captured).

So, to capture the click event everytime, i added a _dopostback
function in javascript code. This made post-back possible for
subsequent clicks on the same list-item.

But i get a problem because of this. Now when I click on a list-item
first time, post-back occurs twice:
-- Once because of javascript function (_dopostback)
-- Secondly, because of autoPostBack property of list-box set to
true.

However, on second click, there occurs only one post-back because of
javascript only. Thats wat I require. Wat i dont require is two post-
backs on first click!!!

Pls tell me how do I prevent javascript function from working on
first
click of the list-item???
At least you can try the following: remember the value of the listbox,
and when an onChange event occurred check if the value has been
changed. When value is changed, do nothing. When it is not changed do
a postback.

Some thoughts:

<asp:DropDownList id="'listboxid'"
onchange="javascript:if(this.options[this.selectedIndex].value==v1)
_dopostback;"....

<script>
var v1 =
document.getElementById('listboxid').options[document.getElementById('listboxid').selectedIndex].value;
</script>

May 24 '07 #2
On 24 mei, 06:51, Garg <shivaniga...@gmail.comwrote:
I had a listbox, whose autoPostBAck property was set to true. So. if
I was clicking on any item for the first time, it caused a successful
post-back. However, if i clicked on the item subsequently, no post-
back occured (because the index of the selected item did not change,
hence the click event was not captured).

So, to capture the click event everytime, i added a _dopostback
function in javascript code. This made post-back possible for
subsequent clicks on the same list-item.

But i get a problem because of this. Now when I click on a list-item
first time, post-back occurs twice:
-- Once because of javascript function (_dopostback)
-- Secondly, because of autoPostBack property of list-box set to
true.

However, on second click, there occurs only one post-back because of
javascript only. Thats wat I require. Wat i dont require is two post-
backs on first click!!!

Pls tell me how do I prevent javascript function from working on
first
click of the list-item???
Why not set the autopostback to false? Then only your javascript will
do its work and you'll get a single postback each time.

May 24 '07 #3

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

Similar topics

3
by: Troy | last post by:
Hello- I have a website that uses a custom built webserver to serve the pages. (Please don't ask me why my boss had his own web server written). I am displaying a log of information that is an...
3
by: Alex | last post by:
Hi!! i have a major problem, and i've been searching for a solution for about 2 weeks, but havent found one. i have to do a POST-Request to a server, but the server shouldnt know my referrer....
5
by: Gary Vidal | last post by:
I have a client side Javascript which checks an OrderQuantityField against a hidden Textbox of the Minimum Order Quantity. I dont want to do validation on a postback. I would like to be able to...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
2
by: sunilthk | last post by:
Hi All, I have a question. If javascript is disabled how asp.net determines which control has caused the post back. As we know that when we clicks on the button the buttons name goes with posted...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
1
by: Garg | last post by:
I had a listbox, whose autoPostBAck property was set to true. So. if I was clicking on any item for the first time, it caused a successful post-back. However, if i clicked on the item...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.