473,396 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to avoid post-back on button (web control) click in asp.net 2.0?

Hi All,

I have a web page where I would like to do certain activities when user
click's a button.
I have used button web control on my page. Each time, I click this
button....page gets posted.
I don't want my page to do "post-back" when i click on button web
control.
is there any way to accomplish this?
Can anyone help me in this regard?

thanks

May 20 '06 #1
7 9978
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I have a web page where I would like to do certain activities when user
click's a button.
I have used button web control on my page. Each time, I click this
button....page gets posted.
I don't want my page to do "post-back" when i click on button web
control.
is there any way to accomplish this?
Can anyone help me in this regard?


If you don't want your button to postback, that is presumably because it can
achieve everything it needs to do client-side i.e. with JavaScript...?

In which case, don't use an <asp:Button> control at all - simply use an HTML
button e.g.

<input type=button id=cmdHello value="Hello" onclick="alert('Hello');">
May 20 '06 #2
write your code like thisin Page_load()
if(!Page.IsPostBack)
{

your code

}
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hi All,

I have a web page where I would like to do certain activities when user
click's a button.
I have used button web control on my page. Each time, I click this
button....page gets posted.
I don't want my page to do "post-back" when i click on button web
control.
is there any way to accomplish this?
Can anyone help me in this regard?

thanks

May 20 '06 #3
You need to use javascript. Check the following
atlas.asp.net

Tasos

May 20 '06 #4
The HTML section in the toolsbox contains plain HTML controls including your
button.
No postbacks..
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> schreef in bericht
news:eg**************@TK2MSFTNGP02.phx.gbl...
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
I have a web page where I would like to do certain activities when user
click's a button.
I have used button web control on my page. Each time, I click this
button....page gets posted.
I don't want my page to do "post-back" when i click on button web
control.
is there any way to accomplish this?
Can anyone help me in this regard?


If you don't want your button to postback, that is presumably because it
can achieve everything it needs to do client-side i.e. with JavaScript...?

In which case, don't use an <asp:Button> control at all - simply use an
HTML button e.g.

<input type=button id=cmdHello value="Hello" onclick="alert('Hello');">

May 20 '06 #5
Are you wanting to post to a different page? If so, there is a
property on the button where you can specify where to post to. If you
are looking for something like javascript, you can use the HTML input,
or put onclick attribute as the javascript you want to do, followed by
"return false;" and i believe that will work for you.

HTH,
Darren Kopp

May 21 '06 #6
That doesn't prevent a post-back. It only prevents the code to be
executed when the post-back happens.

Ankit Aneja wrote:
write your code like thisin Page_load()
if(!Page.IsPostBack)
{

your code

}
"loga123" <vd**********@covansys.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
Hi All,

I have a web page where I would like to do certain activities when user
click's a button.
I have used button web control on my page. Each time, I click this
button....page gets posted.
I don't want my page to do "post-back" when i click on button web
control.
is there any way to accomplish this?
Can anyone help me in this regard?

thanks


May 21 '06 #7
"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:uO**************@TK2MSFTNGP02.phx.gbl...
write your code like thisin Page_load()

if(!Page.IsPostBack)
{

your code

}


How would that stop a postback...?
May 21 '06 #8

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

Similar topics

4
by: Jake Lloyd | last post by:
In "A Note on Security In PHP" (partly in reference to a security flaw that exists or recently did exist in phpBB) at http://nl3.php.net/security-note.php The PHP Group makes this claim: "Every...
22
by: T.S.Negi | last post by:
Hi All, I want to avoid using cursors and loops in stored procedures. Please suggest alternate solutions with example (if possible). Any suggestion in these regards will be appreciated. ...
9
by: iaesun | last post by:
i'm trying to write a batch that will perform a complex task using set-based selects instead of a row-based cursor. let me know if you can help me figure out how. description of what i'm trying...
3
by: Thomas Müller-Lynch | last post by:
How can I avoid late binding with the directive strict = tru My ASP .net-file looks like this <%@DEBUG=true TRACE=true Strict=false EXPLICIT=true% .. dim footerValues as Arra footerValues =...
19
by: Charles Law | last post by:
Take a solution with a project hierarchy along the lines of an n-tier system, so that we have a data layer, business layer and presentation layer. The presentation layer is coupled to the business...
32
by: KK | last post by:
Hello all, I have a unsigned char buffer 'buffer' and I need to convert the first 12 bytes of it into a string. Below is a code that should work, however, how can I avoid reinterpret_cast...
10
by: Noozer | last post by:
I'm writing an ASP application and have a noob question... I have a class that access an MS SQL database. I have another class also accesses an MS SQL database and this second class uses objects...
4
by: gzaxar | last post by:
Hi to all in forum. It is my first post here. I am quite new in MsAccess programming. Here is a problem which i am facing to. I want to keep records of employees CV's. More specifically i want...
3
by: Cirene | last post by:
Building an ASP.NET community site where people can post ads, messages, etc... Based on your experience do you have any suggestions on how to avoid spammers (at least deter them)? Ex: Should...
1
by: nguillot | last post by:
Hello. If I have the following classes: class B {}; typedef B tB; if A is: class A
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.