单击Form标签中的Submit按钮获取Viewstate url

时间:2013-12-04 05:57:18

标签: asp.net forms

我有一个包含输入文本框,一些复选框和提交按钮的表单标记。我需要选中复选框,然后单击按钮,我想在url中将这些选中的值作为查询字符串。这是我的代码

<form method="get" id="CommonSearch" name="All-Search">
 <input type="text" name="keyword" placeholder="@umbraco.library.GetDictionaryItem("SearchTip")" class="form-control cust-txt">
                <input type="submit" class="btn btn-primary sear" name="submit" value="@umbraco.library.GetDictionaryItem("Search")"> 

Listboxes..
</form>

但是当我点击按钮时我会收到网址:

http://localhost:355/product/?chbox=on&chbox=on&__VIEWSTATE=%2FwEPDwUENTM4MQ9kFgJmD2QWAmYPZBYCZg9kFgJmD2QWAgIHD2QWAgIJD2QWAmYPZBYCZhBkZBYCAgEPEA8WBB4ORGF0YVZhbHVlRmllbGQFDGVuZ2xpc2hfbmFtZR4LXyFEYXRhQm91bmRnZBAV7gELQWZnaGFuaXN0YW4HQWxiYW5pYQdBbGdlcmlhDkFtZXJpY2FuIFNhbW9hB0FuZG9ycmEGQW5nb2xhCEFuZ3VpbGxhCkFudGFyY3RpY2ETQW50aWd1YSBhbmQgQmFyYnVkYQlBcmdlbnRpbmEHQXJtZW5pYQVBcnViYQlBdXN0cmFsaWEHQXVzdHJpYQpBemVyYmFpamFuB0JhaHJhaW4KQmFuZ2xhZGVzaAhCYXJiYWRvcwdCZWxhcnVzB0JlbGdpdW0GQmVsaXplBUJlbmluB0Jlcm11ZGEGQmh1dGFuB0JvbGl2aWEWQm9zbmlhIGFuZCBIZXJ6ZWdvdmluYQhCb3Rzd2FuYQ1Cb3V2ZXQgSXNsYW5kBkJyYXppbB5Ccml0aXNoIEluZGlhbiBPY2VhbiBUZXJyaXRvcnkWQnJpdGlzaCBWaXJnaW4gSXNsYW5kcwZCcnVuZWkIQnVsZ2FyaWEMQnVya2luYSBGYXNvB0J1cnVuZGkIQ2FtYm9kaWEIQ2FtZXJvb24GQ2FuYWRhCkNhcGUgVmVyZGUOQ2F5bWFuI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gRnV0dW5hDldlc3Rlcm4gU2FoYXJhBVllbWVuCll1Z29zbGF2aWEGWmFtYmlhCFppbWJhYndlFCsD7gFnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZGRkwslws5YaO3dy5qwgGMMT%2B3QbeXe9qnSJVHl5O1Ub47w%3D&ctl00%24ctl00%24ctl00%24ContentPlaceHolderDefault%24cphcontainermiddle%24%5BSearch%5DShow+Countries_6%24ddlShowCountry=Afghanistan&select2=opt1&select2=opt&keyword=Test&submit=search

有人知道为什么要这个以及如何解决它?

2 个答案:

答案 0 :(得分:0)

您看到了这一点,因为__ViewState是一个隐藏的输入,用于保存页面的视图状态。

ASP.NET webforms使用Viewstate来维护回发之间的状态和数据(以及其他内容)。

有两种主要方法可以解决这个问题:

1)在aspx文件顶部的@Page指令中,您可以设置EnableViewstate="False"

2)使用标准的ASP.NET表单和html或服务器控件(具有runat =“server”属性的控件)和标准回发,并使用Response.Redirect("newurl")。您可以根据page.aspx?parameter=value&parameter2=value2的获取方案在循环中构建新的URL。

答案 1 :(得分:0)

这种情况正在发生,因为您的表单方法设置为“Get”,而不是默认的“Post”。您可能有理由将其设置为“Get”,但如果您不希望追加视图状态字段,请删除method =“get”属性或将其设置为“{{1} }”。