单击超链接时ASP.NET表单标记错误 [英] ASP.NET Form tag error while clicking on a hyperlink

查看:55
本文介绍了单击超链接时ASP.NET表单标记错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试学习MVC,所以我创建了一个ASP.Net应用程序。基本上,我有自己的文件夹。



无论如何,我创建了2个网页(WebForm)首先是default.aspx,它可以被认为是一个菜单。有一个下拉列表,此下拉列表为用户提供了显示其他页面的选项。



例如,当用户从下拉列表中选择departmant选项时,用户应该看到departmaents.aspx。但是页面出现错误而没有数据。该错误是一个经典的aspx错误。



'/PL'UygulamasındaSunucuHatası。



Sayfada tek birsunucutaffı形式etiketi olabilir。



这是default.aspx'背景c#代码;



  protected   void  DropDownList1_SelectedIndexChanged( object  sender,EventArgs e)
{
if (DropDownList1.SelectedIndex == 0
{HyperLink1.Text = Birimler;
HyperLink1.NavigateUrl = http:// localhost:12648 / PL / Birimler.aspx;
}
else if (DropDownList1.SelectedIndex == 1
{
HyperLink1.Text = Personel ;
HyperLink1.NavigateUrl = http:// localhost:12648 / PL / Personel.aspx;
}
else if (DropDownList1.SelectedIndex == 2
{
HyperLink1.Text = Ziyaretci Defteri;
HyperLink1.NavigateUrl = http:// localhost:12648 / PL / ZiyaretciDefteri.aspx;
}
}





我缺少什么?



我搜索但无法解决此问题。谢谢。



Emre。

解决方案

对不起,我在我的asp脚本中使用了2个表单标签。 (我已经从另一个aspx页面移动了elemnts,这是重复的原因)



 <   html     xmlns   =  http://www.w3.org/1999/xhtml >  
< head runat = 服务器 >
< title > < / title >
< style type = text / css >
style1
{
width 100%;
}
style2
{
width 461px;
}
< / style >
< / head >
< body
>
< 表格 id = form2 runat = server >
< div >

< table class = style1 >
< tr >
< td class = style2 >
YeniBölümEkle < / td >
< td > $ b $bKayırlıBölümller< / td >
< / tr > ;
< tr >
< td class = style2 >
< asp:label id = Label1 runat = server text = Bolumİsmi xmlns:asp = #unknown > < / asp:标签 >
< asp:textbox id = txtBolumİsmi runat = server xmlns:asp = #unknown > < / asp:textbox >
< asp:按钮 id = btnBolumEkle runat = server onclick = btnBolumEkle_Click xmlns:asp = #unknown >
Text =YeniBölümEkle/>
< asp:label id = lblMesaj runat = 服务器 > < / asp:label >
< / asp:button > < / td >
< td >
< asp:gridview id = GridView1 runat = 服务器 allowpaging = True xmlns:asp = #unknown >
AutoGenerateDeleteButton =TrueAutoGenerateEditButton =True
AutoGenerateSelectButton =TrueBackColor =YellowPageSize =3>
< / asp:gridview >
< / td >
< / tr >
< tr >
< td class = style2 >
< / td & gt;
< td >
< / td >
< / tr >
< / table >

< / div >
//此表单应删除
< / form >
< 表格 id = form1 < span class =code-attribute> runat = server >
< div >

< / div >
< / form >
//到这里
< / html >


Hello everyone,

I am trying to learn MVC, so I created an ASP.Net application. Basicly, I have the realted folders.

Whatever, I created 2 web pages(WebForm) First is the default.aspx which can be thought as a menu. There is a dropdown list and this dropdown gives the user options to present other pages.

For example, when the user selects the "departmant" option from the dropdown list, the user should see the departmaents.aspx. However the page comes with an error and no data. The error is a classic aspx error.

"'/PL' Uygulamasında Sunucu Hatası.

Sayfada tek bir sunucu tarafı Form etiketi olabilir."

Here is the default.aspx' background c# code;

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (DropDownList1.SelectedIndex ==0)
    {   HyperLink1.Text= "Birimler";
        HyperLink1.NavigateUrl = "http://localhost:12648/PL/Birimler.aspx";
    }
    else if (DropDownList1.SelectedIndex == 1)
    {
        HyperLink1.Text = "Personel";
        HyperLink1.NavigateUrl = "http://localhost:12648/PL/Personel.aspx";
    }
    else if (DropDownList1.SelectedIndex == 2)
    {
        HyperLink1.Text = "Ziyaretci Defteri";
        HyperLink1.NavigateUrl = "http://localhost:12648/PL/ZiyaretciDefteri.aspx";
    }
}



What am I missing?

I searched but couldn't resolve this. Thank you.

Emre.

解决方案

Sorry, ı have used 2 form tag in my asp script. (I have moved form elemnts from another aspx page, that is the cause of duplication)

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 461px;
        }
    </style>
</head>
<body>
    <form id="form2" runat="server">
    <div>
    
        <table class="style1">
            <tr>
                <td class="style2">
     Yeni Bölüm Ekle</td>
                <td>
                    Kayırlı Bölümller</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:label id="Label1" runat="server" text="Bolum İsmi" xmlns:asp="#unknown"></asp:label>
                    <asp:textbox id="txtBolumİsmi" runat="server" xmlns:asp="#unknown"></asp:textbox>
                    <asp:button id="btnBolumEkle" runat="server" onclick="btnBolumEkle_Click" xmlns:asp="#unknown">
                        Text="Yeni Bölüm Ekle" />
                    <asp:label id="lblMesaj" runat="server"></asp:label>
                </asp:button></td>
                <td>
                    <asp:gridview id="GridView1" runat="server" allowpaging="True" xmlns:asp="#unknown">
                        AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" 
                        AutoGenerateSelectButton="True" BackColor="Yellow" PageSize="3">
                    </asp:gridview>
                </td>
            </tr>
            <tr>
                <td class="style2">
                     </td>
                <td>
                     </td>
            </tr>
        </table>
    
    </div>
//This form should be deleted
    </form>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
//Till here
</html>


这篇关于单击超链接时ASP.NET表单标记错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆