fire an event without postback?

W

Will

I am building a control which has some buttons and when
you click a button it moves information from one listbox
to another. this control could be near the bottom of a web
page, so I cannot have the page reloading every time
someone clicks one of the buttons. How can I fire their
events without posting back to the server? Here is an
example of what I mean..

http://www.metabuilders.com/Tools/DualList.aspx


the smack button posts back to the server, but the others
do not.. as near as I can tell no javascript is used..
 
J

Jenny K

Will said:
I am building a control which has some buttons and when
you click a button it moves information from one listbox
to another. this control could be near the bottom of a web
page, so I cannot have the page reloading every time
someone clicks one of the buttons. How can I fire their
events without posting back to the server? Here is an
example of what I mean..

http://www.metabuilders.com/Tools/DualList.aspx


the smack button posts back to the server, but the others
do not.. as near as I can tell no javascript is used..

I didn't look too closely at the ViewSource of the page but it looks like
it's all client-side code. Sure the "Add ->" button is a "submit" button
but the author's also got an onsubmit attribute on his/her <form> tag. So,
there's probably code running to check if a postback is needed when the form
submits on the client.
 
V

Vidar Petursson

Hi

Sure there is Javascript if done on the client
Example
<html>
<head>
<script>
function moveSelItems(f){
f.sel2.options.length = 0;
var e;
for(i=0;i<f.sel1.options.length;i++)
{
e = document.createElement("option");
e.value = f.sel1.options.value;
e.text = f.sel1.options.text;
f.sel2.options.add(e);
}
}
</script>
</head>
<body>
<form>
<select name="sel1">
<option value="1">v1</option>
<option value="2">v2</option>
<option value="3">v3</option>
</select> <input type="button" onclick="moveSelItems(this.form)"
value="Click to add"><br>
<select name="sel2"></select>
</form>
</body>
</html>

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top