Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > LinkButton & Postback

Reply
Thread Tools

LinkButton & Postback

 
 
Eric
Guest
Posts: n/a
 
      05-13-2008
I have a linkbutton on a form that executes a script, it works fine except
that it posts back to the calling form first. Is there a way to prevent
this? I tried setting the PostBackURL property to the form the script
launches but that resulted in some strange behavior.

TIA


 
Reply With Quote
 
 
 
 
Alex Meleta
Guest
Posts: n/a
 
      05-13-2008
Hi Eric,

E.g. you can use this linkbutton .Attributes.Add("onclick", "return false")
if you just need to run script in OnClientClick and prevent postback.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

E> I have a linkbutton on a form that executes a script, it works fine
E> except that it posts back to the calling form first. Is there a way
E> to prevent this? I tried setting the PostBackURL property to the
E> form the script launches but that resulted in some strange behavior.
E>
E> TIA
E>


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      05-13-2008
a LinkButton is an anchor with javascript added to do a postback. if you
don't want to do a postback, don't use a link button, just use an anchor (or
HyperLink). if you just want to call a javascript routine from an anchor, the
usual trick is:

<a href="#" onclick="myfunction(this);return false;" >Click me</a>
or
<a href="javascript:myfunction(this);" >Click me</a>

note: some installs of IE fail to honor return false from an event, and must
include code to cancel event bubbling.

-- bruce (sqlwork.com)


"Eric" wrote:

> I have a linkbutton on a form that executes a script, it works fine except
> that it posts back to the calling form first. Is there a way to prevent
> this? I tried setting the PostBackURL property to the form the script
> launches but that resulted in some strange behavior.
>
> TIA
>
>
>

 
Reply With Quote
 
eric
Guest
Posts: n/a
 
      05-13-2008
Thanks for the responses, the suggestions should do what I'm after.


"Eric" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a linkbutton on a form that executes a script, it works fine except
>that it posts back to the calling form first. Is there a way to prevent
>this? I tried setting the PostBackURL property to the form the script
>launches but that resulted in some strange behavior.
>
> TIA
>



 
Reply With Quote
 
coolit 2011
Guest
Posts: n/a
 
      11-14-2010
Great !!!!
it works.

thank's

> On Tuesday, May 13, 2008 11:28 AM Eric wrote:


> I have a linkbutton on a form that executes a script, it works fine except
> that it posts back to the calling form first. Is there a way to prevent
> this? I tried setting the PostBackURL property to the form the script
> launches but that resulted in some strange behavior.
>
> TIA



>> On Tuesday, May 13, 2008 11:55 AM Mark Rae [MVP] wrote:


>> Do you actually require a round-trip to the server, or do you just need to
>> go to another page...?
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net



>>> On Tuesday, May 13, 2008 1:25 PM brucebarke wrote:


>>> a LinkButton is an anchor with javascript added to do a postback. if you
>>> don't want to do a postback, don't use a link button, just use an anchor (or
>>> HyperLink). if you just want to call a javascript routine from an anchor, the
>>> usual trick is:
>>>
>>> <a href="#" onclick="myfunction(this);return false;" >Click me</a>
>>> or
>>> <a href="javascript:myfunction(this);" >Click me</a>
>>>
>>> note: some installs of IE fail to honor return false from an event, and must
>>> include code to cancel event bubbling.
>>>
>>> -- bruce (sqlwork.com)
>>>
>>>
>>> "Eric" wrote:



>>>> On Tuesday, May 13, 2008 2:34 PM eric wrote:


>>>> Thanks for the responses, the suggestions should do what I am after.



>>>>> On Tuesday, May 13, 2008 11:39 PM Alex Meleta wrote:


>>>>> Hi Eric,
>>>>>
>>>>> E.g. you can use this linkbutton .Attributes.Add("onclick", "return false")
>>>>> if you just need to run script in OnClientClick and prevent postback.
>>>>>
>>>>> Regards, Alex
>>>>> [TechBlog] http://devkids.blogspot.com
>>>>>
>>>>> E> I have a linkbutton on a form that executes a script, it works fine
>>>>> E> except that it posts back to the calling form first. Is there a way
>>>>> E> to prevent this? I tried setting the PostBackURL property to the
>>>>> E> form the script launches but that resulted in some strange behavior.
>>>>> E>
>>>>> E> TIA
>>>>> E>



>>>>>> On Wednesday, July 08, 2009 1:18 PM ross wrote:


>>>>>> You are required to be a member to post replies. After logging in or becoming a member, you will be redirected back to this page.



>>>>>> Submitted via EggHeadCafe
>>>>>> Custom task processes in SharePoint Designer Workflows
>>>>>> http://www.eggheadcafe.com/tutorials...workflows.aspx

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keep LinkButton from postback DavidC ASP .Net 1 02-03-2010 09:09 PM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net 3 09-08-2005 09:41 AM
Linkbutton does not look like a linkbutton Sathyaish ASP .Net Datagrid Control 1 09-08-2005 08:44 AM
Disable Linkbutton Before Postback? Al Cohen ASP .Net 6 12-28-2004 05:23 PM
LinkButton CommandArgument bound property loses value on postback =?Utf-8?B?QmVuamFtaW4gSm9sZGVyc21h?= ASP .Net 2 08-21-2004 05:57 PM



Advertisments