473,654 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LinkButton & Postback

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
Jun 27 '08 #1
4 2369
"Eric" <as**@a.comwrot e in message
news:uR******** ******@TK2MSFTN GP03.phx.gbl...
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.
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

Jun 27 '08 #2
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

EI have a linkbutton on a form that executes a script, it works fine
Eexcept that it posts back to the calling form first. Is there a way
Eto prevent this? I tried setting the PostBackURL property to the
Eform the script launches but that resulted in some strange behavior.
E>
ETIA
E>
Jun 27 '08 #3
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="myfunc tion(this);retu rn false;" >Click me</a>
or
<a href="javascrip t:myfunction(th is);" >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
Jun 27 '08 #4
Thanks for the responses, the suggestions should do what I'm after.
"Eric" <as**@a.comwrot e in message
news:uR******** ******@TK2MSFTN GP03.phx.gbl...
>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

Jun 27 '08 #5

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

Similar topics

4
5843
by: sef | last post by:
i have a server-side script that executes this: linkbutton1.Attributes.Add("onClick", "linkClicked();"); the client-side code has an html image control <img id="image1"> the client-side javascript function linkClicked looks like this void linkClicked(object sender, System.EventArgs e){ image1.src = "test.jpg";
2
5582
by: Dave | last post by:
Hi, I have a datagrid with a Templated column below. I want to execute some javascript before the postback to show a hidden "div" tag with static message of "Please Wait..." since the query takes a few seconds. The js function simply sets the css style to display. <asp:TemplateColumn> <ItemTemplate> <asp:LinkButton Runat="server" CommandName="Select" ID="lbtnCompanyName"> <%# DataBinder.Eval(Container.DataItem, "CompanyName")%>...
10
2844
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I have to add a datalist control. Using this datalist control I should be able to add edit, modify and cancel the items listed in this control. Here is how I designed. I used placeholder to add the controls dynamically to the page on the click...
3
3975
by: Rob Meade | last post by:
Hi all, I have a bit of code that programmatically adds some table cells/rows to a table. The last cell adds a LinkButton control, I call it like this: Cell.Controls.Add(deleteRecipientLink(objReader("NotificationID"))) I feed it with an ID from my database table.
10
4614
by: Vi | last post by:
Hi, I'm trying to dinamically add LinkButton Controls to a web form. I do something like: for(i=1;i<=someVariable;i++) { LinkButton PageLink = new LinkButton(); PageLink.CommandName = i.ToString(); PageLink.Text = "Page " + i;
1
2309
by: geronimi | last post by:
I want to create a linkbutton in a cell because not every row needs one (so I can't setup a linkbuttoncolumn instead of a boundcolumn.) First, i create a linkbutton in the datagrid_ItemDataBound : Dim linkButton As New LinkButton linkButton.Text = name linkButton.CommandName = "PassSelectedClient" linkButton.CommandArgument = id I add it to the controls
2
2703
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous 1 2 3 4 5 ... Next Last >> I have achieved the first/previous/next/last buttons quite easily as follows in the ASPX (1.1) page:
13
10162
by: rn5a | last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to show him 5 LinkButtons (one for each order) so that when he clicks the first LinkButton, he would be shown the details of his first order. Likewise if he clicks the second LinkButton, he will be shown the details of the second order he had placed. The Text of the LinkButtons will be 1 2 3 etc. So this user would see 1 2 3 4 5 as the LinkButtons. The problem is...
6
2590
by: ree321 | last post by:
I have a linkbutton which is added to a column in a datagrid dynamically using a template I created. When I change the data in it by not databinding and then when I later retreive the data from the control after a post back it goes back to the value which was dynamically bounded. I have set up similar process with a checkbox template and it remebers the value. Are Linkbuttons not capable of this? and should I use something else?
0
8370
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.