admin管理员组文章数量:1384803
I have an asp:Button
control like this;
<asp:Button ID="btnPayCC" CssClass="paymentButton" runat="server" Text="ONAYLA"
OnClientClick="if(!doPostBack()) return false; frmMaster.target='_blank'"
PostBackUrl="" OnClick="btnPayCC_Click" />
And doPostBack
javascript function is;
function doPostBack()
{
__doPostBack('<%= btnPayCC.ClientID %>', '');
return true;
};
When I clicked the button, then it opens new page(google) as I wish,
But do not postback into button control's OnClick
event.
What is the problem? How can I solve it?
I have an asp:Button
control like this;
<asp:Button ID="btnPayCC" CssClass="paymentButton" runat="server" Text="ONAYLA"
OnClientClick="if(!doPostBack()) return false; frmMaster.target='_blank'"
PostBackUrl="http://www.google." OnClick="btnPayCC_Click" />
And doPostBack
javascript function is;
function doPostBack()
{
__doPostBack('<%= btnPayCC.ClientID %>', '');
return true;
};
When I clicked the button, then it opens new page(google.) as I wish,
But do not postback into button control's OnClick
event.
What is the problem? How can I solve it?
Share Improve this question edited Dec 3, 2013 at 12:24 Mehmet Ince asked Mar 27, 2013 at 15:04 Mehmet InceMehmet Ince 4,18914 gold badges47 silver badges65 bronze badges 4- 2 You can only PostBack to one place. You're either posting "back" to the google url or you're posting back to your own page. Both can't happen without separate requests. – Joel Etherton Commented Mar 27, 2013 at 15:07
- Thanks @JoelEtherton, I wonder, is there any alternative solution to do this job (calling a c# function using doPostBack vs.)? – Mehmet Ince Commented Mar 27, 2013 at 15:09
- I would remend posting back to your local page, doing whatever verification you need then REposting to google. They are self-contained actions so shouldn't be dependent on each other. – Joel Etherton Commented Mar 27, 2013 at 15:43
- @MehmetInce you can call your javascript from the code behind. – Nudier Mena Commented Mar 27, 2013 at 16:58
1 Answer
Reset to default 5I had the same problem. I solved it by adding a Response.Redirect("url") at the end of my onClick event for the Button and removing the PostbackUrl attribute from the button so that is uses autopostback to the same url. IE:
protected void Button_Click(object sender, EventArgs e)
{
//do your button click events here
Response.Redirect("~/url.aspx");
}
and
<asp:Button ID="Button" runat="server" CausesValidation="false" OnClick="Button_Click">
本文标签: cUsing OnClick event with PostBackUrl attribute of aspButtonStack Overflow
版权声明:本文标题:c# - Using OnClick event with PostBackUrl attribute of asp:Button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744501852a2609366.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论