-2
我有一個asp.net web應用程序項目,其中包括總共三頁,即登錄頁面,首頁和網頁視圖的頁面。當我運行應用程序時,它正常工作,但是當我點擊任何鏈接或任何按鈕時,它將指向第一頁。我創建了甚至新的頁面也gird查看但仍然問題依然存在。我不知道問題出現在網格視圖或數據庫中。請在這方面協助我,因爲我在這個項目上做了很多工作。點擊任何鏈接或按鈕重定向到另一個頁面asp.net
下面是它再次被重定向第一頁的代碼,並再次
<asp:Content ID="FormContentHolder" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="container">
<div class="row">
<div id="logobar">
<h1>
<img src="http://localhost:50090/uploads/icons/logo.png" style="height: 99px" /> Document Expiry Alert System</h1>
</div>
</div>
<div class="row">
<div>
<hr />
</div>
<div id="container-fluid">
<div class="col-md-3">
<div id="icons">
<div>
<a href="DatabaseGView.aspx">
<img class="img-responsive" src="uploads/icons/update.png" /></a>
<a href="DatabaseGView.aspx">Update</a>
</div>
</div>
</div>
<div class="col-md-9">
<div class="form-group">
<div class="text-left">
<h1>Students Database</h1>
</div>
<table class="">
<tr>
<td class="" style="width: 30%">Registration No.</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="ID" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="" style="width: 30%">First Name</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="FN" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Last Name</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="LN" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Nationality</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:DropDownList ID="Country1" runat="server" CssClass="form-control box-margin-8" Width="190px">
/--Here was very long list of countries so i removed--/
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="">Email</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="email" runat="server" CssClass="form-control box-margin-8" TextMode="Email" Width="190px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Passport No</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="passportNo" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Place of Issue</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:DropDownList ID="PlaceOfIssue" runat="server" CssClass="form-control box-margin-8" Width="190px">
<asp:ListItem Value="AF">Afghanistan</asp:ListItem>
/--Here was very long list of countries so i removed--/
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="">Issue</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="issue" runat="server" TextMode="Date" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Expiry</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="Expiry" runat="server" Width="190px" TextMode="Date" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Visa No</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="VisaNo" CssClass="form-control box-margin-8" runat="server" Width="190px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Visa Expiry</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="VisaExpiry" runat="server" Width="190px" TextMode="Date" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">Emirates ID No</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="EmiratesNo" CssClass="form-control box-margin-8" runat="server" Width="190px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="">ID Expiry</td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:TextBox ID="EmiaratesExpiry" runat="server" Width="190px" TextMode="Date" CssClass="form-control box-margin-8"></asp:TextBox>
</td>
</tr>
<tr>
<td class=""> </td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;"> </td>
</tr>
<tr>
<td class=""> </td>
<td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
<asp:Button ID="submitt" runat="server" class="btn" OnClick="submitt_Click" Text="Submit" />
<input id="Reset1" type="button" value="reset" class="btn" onclick="myFunction()" />
<asp:Label ID="Label1" runat="server" />
<asp:Label ID="Label2" runat="server" />
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</asp:Content>
這裏是第二頁: -
<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="DatabaseGView.aspx.cs" Inherits="Document_Expiry_Reminder.DatabaseGView" %>
<asp:Content ID="FormContentHolder" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
<link href="css/bootstrap.css" rel="stylesheet" />
<div class="container">
<div class="img-responsive" style="background-color: none;">
<h1>
<img src="http://localhost:50090/uploads/icons/logo.png" style="height: 99px" /> Student Database Administration</h1>
</div>
<div class="row">
<div>
<hr />
</div>
</div>
<div class="displayflex">
<div class="row">
<div class="col-md-1">
<a href="FrontPage.aspx">
<img class="img-responsive" src="uploads/icons/add.png" /></a>
<a href="FrontPage.aspx">Add</a>
</div>
</div>
</div>
</div>
<div class="row" style="margin-left: 5px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" /> <asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select Document</asp:ListItem>
<asp:ListItem>Passport Expiry</asp:ListItem>
<asp:ListItem>Visa & Emirates Expiry</asp:ListItem>
</asp:DropDownList>
From Date
<asp:TextBox ID="fromDate" runat="server" TextMode="Date"></asp:TextBox>
To Date
<asp:TextBox ID="toDate" runat="server" TextMode="Date"></asp:TextBox>
<asp:Button ID="Search" runat="server" OnClick="Search_Click" Text="Search" />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1" OnRowEditing="GridView1_RowEditing" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="ID" HeaderText="Reg No" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="FN" HeaderText="First" SortExpression="FN" />
<asp:BoundField DataField="LN" HeaderText="Last" SortExpression="LN" />
<asp:BoundField DataField="Country1" HeaderText="Country" SortExpression="Country1" />
<asp:BoundField DataField="gender" HeaderText="Gender" SortExpression="gender" />
<asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
<asp:BoundField DataField="PassportNo" HeaderText="Passport" SortExpression="PassportNo" />
<asp:BoundField DataField="PlaceOfIssue" HeaderText="Place Of Issue" SortExpression="PlaceOfIssue" />
<asp:BoundField DataField="Issue" HeaderText="Issue" SortExpression="Issue" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="Expiry" HeaderText="Expiry" SortExpression="Expiry" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="VisaNo" HeaderText="Visa" SortExpression="VisaNo" />
<asp:BoundField DataField="VisaExpiry" HeaderText="Visa Expiry" SortExpression="VisaExpiry" DataFormatString="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="EmiratesNo" HeaderText="Emirates ID" SortExpression="EmiratesNo" />
<asp:BoundField DataField="EmiratesExpiry" HeaderText="ID Expiry" SortExpression="EmiratesExpiry" DataFormatString="{0:MM/dd/yyyy}" />
</Columns>
<EditRowStyle BackColor="Black" ForeColor="#0033CC" />
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" BorderStyle="Groove" />
<PagerStyle CssClass="pagination-ys" BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<RowStyle BackColor="White" ForeColor="#003399" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#99CCFF" Font-Bold="True" ForeColor="#CCFF99" />
<SortedAscendingCellStyle BackColor="#EDF6F6" />
<SortedAscendingHeaderStyle BackColor="#0D4AC4" />
<SortedDescendingCellStyle BackColor="#D6DFDF" />
<SortedDescendingHeaderStyle BackColor="#002876" />
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SzabistStudentsConnectionString3 %>" DeleteCommand="DELETE FROM [Students] WHERE [ID] = @original_ID" InsertCommand="INSERT INTO [Students] ([ID], [FN], [LN], [Country1], [gender], [email], [PassportNo], [PlaceOfIssue], [Issue], [Expiry], [VisaNo], [VisaExpiry], [EmiratesNo], [EmiratesExpiry]) VALUES (@ID, @FN, @LN, @Country1, @gender, @email, @PassportNo, @PlaceOfIssue, @Issue, @Expiry, @VisaNo, @VisaExpiry, @EmiratesNo, @EmiratesExpiry)" SelectCommand="SELECT * FROM [Students]" UpdateCommand="UPDATE [Students] SET [FN] = @FN, [LN] = @LN, [Country1] = @Country1, [gender] = @gender, [email] = @email, [PassportNo] = @PassportNo, [PlaceOfIssue] = @PlaceOfIssue, [Issue] = @Issue, [Expiry] = @Expiry, [VisaNo] = @VisaNo, [VisaExpiry] = @VisaExpiry, [EmiratesNo] = @EmiratesNo, [EmiratesExpiry] = @EmiratesExpiry WHERE [ID] = @original_ID" OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="String" />
<asp:Parameter Name="FN" Type="String" />
<asp:Parameter Name="LN" Type="String" />
<asp:Parameter Name="Country1" Type="String" />
<asp:Parameter Name="gender" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="PassportNo" Type="String" />
<asp:Parameter Name="PlaceOfIssue" Type="String" />
<asp:Parameter DbType="Date" Name="Issue" />
<asp:Parameter DbType="Date" Name="Expiry" />
<asp:Parameter Name="VisaNo" Type="String" />
<asp:Parameter DbType="Date" Name="VisaExpiry" />
<asp:Parameter Name="EmiratesNo" Type="String" />
<asp:Parameter DbType="Date" Name="EmiratesExpiry" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="FN" Type="String" />
<asp:Parameter Name="LN" Type="String" />
<asp:Parameter Name="Country1" Type="String" />
<asp:Parameter Name="gender" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="PassportNo" Type="String" />
<asp:Parameter Name="PlaceOfIssue" Type="String" />
<asp:Parameter DbType="Date" Name="Issue" />
<asp:Parameter DbType="Date" Name="Expiry" />
<asp:Parameter Name="VisaNo" Type="String" />
<asp:Parameter DbType="Date" Name="VisaExpiry" />
<asp:Parameter Name="EmiratesNo" Type="String" />
<asp:Parameter DbType="Date" Name="EmiratesExpiry" />
<asp:Parameter Name="original_ID" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</asp:Content>
從第二頁中,任意點擊在鏈接或按鈕它重定向到fronpage.aspx這是我的項目中的firts頁面
我們如何在沒有看到代碼的情況下爲您提供幫助? – ADyson
先生,我已經上傳了代碼,請協助 –
這些鏈接:'Add'將明確指向首頁。這是可以預料的。我還可以在第二頁看到兩個名爲「搜索」的按鈕,點擊時每個按鈕都會調用不同的代碼隱藏方法。這些方法是什麼?會導致重定向的東西?您還應該檢查您的Page_Load方法以及您的主頁面中處理的所有事件,以查看它們是否包含重定向代碼。如果您不確定發生了什麼,請在您的代碼中設置斷點以查找重定向發生的時刻。如果你還不確定,請在這裏發佈代碼 – ADyson