Under what circumstances do you want to cancel the postback?
Rhys
"Vampireware /n/,a project, capable of sucking the lifeblood out of anyone unfortunate enough to be assigned to it, which never actually sees the light of day, but nonetheless refuses to die."
OK - here is the sittuation - Im developing a online Chat app - I wanted the on click event of the send button not to reload the page .... I guess this would be very easy in ASP.NET 2.0 as they've implemented client_side events. The other thing has well , i want to update the 'ChatArea' textbox without a refresh , will this be possible?
I can't remember the axact syntax but you can do something like OnClick="return JavaScript:someFunction();" as an attribute of the button control. Then in your javascript function do something like the following:
<script language='JavaScript'>
function someFunction()
{
if(some dondition here == true)
{
return true;
}
else
{
return false;
}
}
</script>
Returning false will prevent the postback from occurring.
Guys, thank you for all your comments - but i think I need to explain the exact sittuation:
OK I receive a string with the new chat message from a timer, I then need to update the textbox.... I tried using javascript ... Using Page.RegisterStartupScript and a view others - the problem seem to be that the functio does not get called if my code runs from a sub / function - What I mean is , if a call the function from a button_click sub it works... Even tried using button_click(nothing,nothing)...
Ok , second problem ,
I want to call a asp function which basicly sends a message and add thext to my textbox - Here i want to do all this without "REFRESHING" the page ...
So, your problem number one is that you want your your application to post to a remote server on a timed basis, check for new 'chat' text to display and display it in the text box of your application, without the displayed page in it's entirety posting to the host server and refreshing?
Rhys
"Vampireware /n/,a project, capable of sucking the lifeblood out of anyone unfortunate enough to be assigned to it, which never actually sees the light of day, but nonetheless refuses to die."
So if you combine a timer with the methodology provided in that very handy link by ca8msm you should be able to work out about posting page elements rather than the entire page which is what you want, however I feel it unlikely that you can update a control on the client from the server without refreshing at least the control you want to update.
Honestly, I think you need to look closely at ca8msm's link and make an assessment of whether what you want to do is realistically acheivable in .Net 1.1.
"Vampireware /n/,a project, capable of sucking the lifeblood out of anyone unfortunate enough to be assigned to it, which never actually sees the light of day, but nonetheless refuses to die."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.