Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends,

i want set Autopostback = false in Button Property. is it possible to set like that?

if i set like that i want perform below code

if(!Ispostback)
{
enter here
}
Posted
Updated 22-Jul-15 1:19am
v2
Comments
Sajith Dilhan 22-Jul-15 7:35am    
If you want to stop the postback when click on the button, then set the button onclientclick="return false;" it will prevent postbacks. But the code you provided will check the page postback. If you prevent the button autopostback then the page will not be postedback and your code will be useless.

Button control has no AutoPostback attribute to set as the purpose of the control is to post back...
You can do one of these:
1. Use a standard input button
2. Write event handler for OnClientClick[^] that will block postback whenever you need
 
Share this answer
 
Comments
Member 11384516 22-Jul-15 7:50am    
hi Kornfeld Eliyahu Peter,

why i was used that concept means when page refresh automatically login button fire.

protected void btnLogin_Click(object sender, EventArgs e)
{
entered here
}

you have any idea? to solve this problem
Kornfeld Eliyahu Peter 22-Jul-15 7:51am    
I do not understand you...
F-ES Sitecore 22-Jul-15 8:11am    
You will have some javascript somewhere that is clicking the button or submitting the form. Try your page with javascript disabled to see if it still happens.
can you please elaborate your question further? what is the purpose? do you want to shift control to server side on click? or do you want to invoke client side methods onclick?
 
Share this answer
 
Comments
Member 11384516 22-Jul-15 9:33am    
hi Faaiz Shabbir

Actually when i entered text box page automatically refresh and invoke to Login Button

this both control i mention in master page


like

protected void btnLogin_Click(object sender, EventArgs e)
{
invoke/fire here
}

this my question


if you have any idea?
Faaiz Shabbir 9-Oct-15 9:49am    
added a solution.. hope it helps
you can use:


// and script:
$(.btn1).click(function(){
$.ajax({
type: "POST",
url: 'Default.aspx/Method1',
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",

});
})

Server Side:
[WebMethod] //Default.aspx.cs
public static void Method1()
{
//Your Logic
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900