帮助我不能使用两个Asp.Net按钮和一个Asp.Net Post Act [英] Help I Cant Use Two Asp.Net Button And One Asp.Net Post Act
本文介绍了帮助我不能使用两个Asp.Net按钮和一个Asp.Net Post Act的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Food1.aspx.cs" Inherits="Food1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style1
{
width: 165px;
}
.style2
{
width: 475px;
}
</style>
</head>
<body>
<form id="form1" runat="server" action="https://test.switch.com" method="post" >
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class fdd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Test.aspx");
}
}
两个按钮onclick重定向到https://test.switch.com。我想要按钮2重定向to test.aspx
Both buttons onclick redirects to https://test.switch.com .i want button two to redirect to Test.aspx
推荐答案
类似于:
Something like:
<asp:button id="Button1" runat="server" postbackurl="~/Test.aspx" causesvalidation="false" text="Button" />
从< form>中删除操作属性如下所示。
ie
Remove action property from <form> as below.
i.e
<form id="form1" runat="server" method="post">
</form>
< / form>
或者Else将PostbackUrl属性提供给你想要不同行为的按钮。
</form>
Or Else Provide PostbackUrl property to the button where u want different behaviour.
这篇关于帮助我不能使用两个Asp.Net按钮和一个Asp.Net Post Act的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文