Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Dear All,
 
Here my question is how can stop the page_load event when i press button.
 
i want to execute only Button Click Event. is it possible???
 
Ok,
 
When I Was Set
if (!Page.IsPostBack)
{
   LoadCompany();
   LoadDesignation();
   LoadCategories();
   LoadStatus();
}
All Above Methods For the bind DropDownList.
 
Then On Button Click Event Not Execute this Code so my All Methods Not Call and so that My DropdownList show blank value.
and on button click not execute proper selected dropDownlist value.

 

Pleas Help Me.
Thank You.
Posted 29-May-12 23:50pm
Edited 30-May-12 0:28am
v3
Comments
John Orendt at 30-May-12 5:54am
   
Short answer is No. However you can leave the page_load method blank.
sanjeev kumar sharma Eng at 30-May-12 5:55am
   
why you want to do so. and what do you want to do in button click event
John Orendt at 30-May-12 6:00am
   
You probably want to use IsPostBack flag in Page_Load
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi ,
You can't it's Default behavior for button , Instead of using Server side controls use HTML INPUT and use JavaScript
Best Regards
M.Mitwalli
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

No.
When your user presses a button, it starts an instance of your application on the server and automatically executes the page_load event.
 
Instead, use IsPostBack to prevent the page load event changing user data - when the used presses a button it will be set to true.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

It depend on your code that you written on the button click event, If you do not want to postback the page then I suggest you to use jQuery Ajax from the following LINK. In this technique postback not happen and hence only your button click code will work.
hope this help you
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

I have to say, you can do it. why don't you rethink on the desired behavior and redesign your strategy.
 
Although, If your button click event is not dependent on any other control of the page and is not using any other values from the page, you can disable the postback and move the code of button into other page that can be called using XMLhttpRequest. (perhaps that not what you are looking for)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

it is not possible. if you want to redirect to any page than you can set PostBackUrl property. than your page will redirect to on which page you define in postbackurl without postback. if you are not redirecting to another page than in page_load check ispostback property to nothing to do in pageload event.
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

Use PageMethod to avoid full page life cycle. It will directly hit a method in the code behind.
Here: PageMethod[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

i was change EnableViewState property of the DropDownList set as Fals..
so it create problem.
Now Set as true then it work Proper.
 
Thanks.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 209
1 Sergey Alexandrovich Kryukov 201
2 Nirav Prabtani 198
3 Mika Wendelius 170
4 OriginalGriff 167
0 Nirav Prabtani 398
1 OriginalGriff 292
2 Sergey Alexandrovich Kryukov 251
3 Mika Wendelius 185
4 Abhinav S 180


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100