Urlrewriting.net IsPostBack始终为false [英] Urlrewriting.net IsPostBack always false

查看:82
本文介绍了Urlrewriting.net IsPostBack始终为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重写URL Urlrewriting.net,遇到了一个似乎很常见的问题,但我似乎可以解决它.我将介绍一个简化的案例.

I am working on rewriting URLs Urlrewriting.net, and have run into what seems to be a common problem but I can seem to fix it. I'll present a simplified case.

URL重写符合以下规则:

The URL rewriting is working perfectly with the rule:

<urlrewritingnet rewriteOnlyVirtualUrls="true" defaultPage="default.aspx" defaultProvider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
   <rewrites>
       <add name="catalog" virtualUrl="^~/catalog/(.*)/(.*).aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/catalog.aspx?cid=$1&amp;c=$2" ignoreCase="true"/>
   </rewrites>
</urlrewritingnet>

在页面上,我有一个带有2个asp:buttons的DataList.单击后,页面将刷新,但不执行任何操作.

On the page I have a DataList with 2 asp:buttons inside. When clicked, the page refreshes but does nothing.

我关注了

I followed ScottGu's article to impliment a form control adapter to rewrite the action of the form to match the rewritten URL.

浏览器中的页面URL:http://...../dev/catalog/13/Music.aspx

Page URL in the browser: http://...../dev/catalog/13/Music.aspx

<form name="aspnetForm" method="post" action="/dev/catalog/13/Music.aspx" id="aspnetForm"> 

现在我在表单操作中看到正确的URL,并且在调试时可以看到页面加载事件触发.

I now see the correct URL on the form action, and when debugging I can see the page load event firing.

现在的问题是,每次页面加载Page.IsPostback为false时,都会导致页面重新绑定DataList,因此忽略了按钮应触发的ItemCommand.

The problem now is that every time the page loads Page.IsPostback is false, causing the page to rebind the DataList and therefore ignore the ItemCommand the buttons should be triggering.

if (!Page.IsPostBack)
     PopulateControls();

我正在使用.NET 3.5 SP1,母版页上有一个ScriptManager,但此页上没有UpdatePanel.我还尝试过重置Form.Action属性,并以相同的结果绕过ScottGu的解决方案.如果我不使用重写器直接进入页面URL,一切正常.

I'm using .NET 3.5 SP1, there is a ScriptManager on the master page but no UpdatePanel on this page. I've also tried resetting the Form.Action property and bypassing ScottGu's solution with the same result. If I go to the page URL directly without using the rewriter everything works fine.

我想念什么?

推荐答案

这是LinkBut​​ton问题,应该从页面中删除所有的linkbutton,包括母版页.

It's the LinkButton problem, all the linkbutton should removed from the page include the master page.

这篇关于Urlrewriting.net IsPostBack始终为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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