fire an event without postback?

  • Thread starter Thread starter Will
  • Start date Start date
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..
 
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.
 
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
==============================
 
Back
Top