How can I dynamically create an ASP:Button that causes no postback inside an UpdatePanel?
문제
I have a page some 2 ASP Tabs and with an UpdatePanel on the first tab. Inside the update panel (on page_load), I dynamically create a table that contains rows with cells for an image, some text, and an ASP:Button. I'd like the button, when clicked to switch tabs from the first to the second. Instead, all it does is refresh the updatepanel it resides in. How can I stop it from behaving that way? How do I get it to perform a function of my own design, instead of posting?
Thank you,
해결책
You can add javascript click event and stop it to do post back by returning false;
In Code behind, where you add button dynamically.
btnChangeTab.Attributes.Add("onclick", "return YourJavascriptFunction();");
In Client side.
<script type="text/javascript">
function YourJavascriptFunction()
{
//Your javascript code here
return false; //the will stop from postback
}
</script>
제휴하지 않습니다 StackOverflow