您不会相信我,但是这种情况正在发生. [英] You won't believe me, but this IS happening.

查看:77
本文介绍了您不会相信我,但是这种情况正在发生.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中包含用于编辑交易明细的表格.
如果表单在其查询字符串中收到交易编号,则表示它正在编辑现有交易.如果不是这样的话,这是新协议.

到目前为止一切都很好.

我在表格上设置了一些验证器.

我的问题是验证者的行为会有所不同,具体取决于这是新交易还是现有交易.同样,基于相同的新/旧情况,某些文本框的文本更改事件将触发或不触发.

简而言之,当文本在我的一个文本框中发生更改时,在编辑现有交易时,一切都将正常进行.对于新交易",其他所有验证器都会触发,其中包括您所期望的验证器.

我不骗你

所以呢?找出现有交易运行哪些不同的代码,这将向您显示出什么问题.

好吧.我通过注释掉代码行来缩小问题的范围,直到找到可以在编辑现有记录时打开和关闭不良行为的特定代码行.而且这是完全没有意义的代码行,完全没有连接到导致问题的文本框.

我现在可以在这里找到尽可能多的代码,如果有人需要更多的代码,我会发布它.我几乎不再关心该错误了,这是弄清楚到底发生了什么的挑战.

这是我的页面加载量:

I have a page that contains a form for editing details of a deal.
If the form receives a deal number in it''s querystring it knows it''s editing an existing deal. If not it''s a new deal.

So far so good.

I have some validators set up on the form.

My problem is that the validators are behaving differently depending on whether this is a new deal or an existing deal. Also the text changed event for some text boxes fire or don''t fire based on the same new/old situation.

In short, when the text changes in one of my text boxes, when editing an existing deal everything works. For New deals all the other validators fire, exept the one you''d expect.

I kid you not.

So what? Figure out what different code runs for an existing deal and that''ll show you what''s wrong.

Well. I''ve narrowed down the problem by commenting out lines of code until I found a specific line of code that can toggle the bad behaviour on and off when editing an existing record. And it''s a completely meaningless line of code, completely unconnected to the Textbox that''s causing the trouble.

Here''s as much of the code as I can get up here right now, if anyone needs more I''ll post it. I almost don''t care about the bug any more, It''s the challenge of figuring out what the hell is going on.

Here''s my page load:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    ' Must Set Up Event Handlers each time, even if this is a PostBack
    SetUpEventHandlers()
    SetUpLookUpDialogs()
    SetUpCulture()

    If Page.IsPostBack Then Exit Sub

    ' Show and Enable Action Buttons on WorkflowFrameCommon
    Master.ShowButtons(WorkflowFrameCommonButtons.All)
    Master.EnableButtons(WorkflowFrameCommonButtons.Home + WorkflowFrameCommonButtons.Save)
    LoadDropDowns()

    DealToScreen(GetDealFromQueryString())
End Sub



最后一行代码之前的所有内容都可以正常工作.
代码的触发行在DealToScreen内部.

GetDealFromQueryString返回一个Deal对象,该对象可以是现有交易,也可以是全新交易:



Everything before that last line of code works fine.
The trigger line of code is inside DealToScreen.

GetDealFromQueryString returns a Deal object which is either the existing deal, or a brand new deal:

Private Function GetDealFromQueryString() As PipelineDeal
    If Request.QueryString("DealNumber") Is Nothing Then
        Return New PipelineDeal
    Else
        Dim dal As New PipelineDAL(SQLServerDataConnection.GetConnection())
        Return dal.SelectById(Request.QueryString("DealNumber"))
    End If
End Function



DealToScreen本身只是获取Deal对象的属性,并将值粘贴到屏幕上的文本框中.

这是东西.这些简单的代码行之一搞砸了我的验证.



DealToScreen itself simply takes the properties of the Deal Object and sticks the values into the text boxes on the screen.

Here''s the thing. One of those simple lines of code screws up my validation.

Me.txtClientProjectName.Text = deal.ClientProjectName



ClientProjectName是一个简单的字符串属性.

至于具体正在发生/未发生的事情:

我为完全不同的文本框设置了事件处理程序,
不是上面提到的那个.

在上面的页面加载中看到的SetUpEventHandlers负责进行设置:



ClientProjectName is a simple string property.

As to what specifically is happening/not happening:

I have set up an event handler for a completely different textbox,
not the one mentioned above.

The SetUpEventHandlers seen in the page load above takes care of setting that up:

AddHandler target.TextChanged, AddressOf CurrencyChanged



根据是否在DealToScreen中注释掉简单的代码分配行,此事件处理程序将触发.

现在,在这一点上,您正在考虑还有其他我要告诉您的内容.我正在改变其他事情.没有.
但情况变得更糟.

在编辑现有记录时,可以通过注释掉任务行来启用和禁用不良行为.

因此,我尝试在创建新记录时打开和关闭行为.
我不能.

无论是新交易还是现有交易,我注释掉的代码行都会运行.唯一的区别是,对于新交易,ClientProjectName为Nothing.

因此,我对实际的字符串值进行了硬编码,以期在创建新交易时获得良好的行为.

没有什么.它不起作用.

我不希望有人坐在这里看着它就不知道解决方案,但是您见过这种行为吗?

我尝试过重启等.

昨晚我住进了一家名为我的智囊团"的酒店,我认为我不会很快退房.

-Rd



Depending on whether or not I comment out the simple assignment line of code in DealToScreen, this event handler will fire or not.

Now, at this point you are thinking there''s something else I''m not telling you. Something else I''m changing. There isn''t.
But it gets worse.

I can toggle the bad behaviour on and off by commenting out the assignment line when editing an existing record.

So, I try toggling the behaviour on and off when creating a new record.
I can''t.

The line of code that I comment out runs whether it''s a New deal or an existing deal. The only difference is that for a new deal deal.ClientProjectName is Nothing.

So I hard code an actual string value, hoping to get the good behaviour when creating a new deal.

Nothing. It doesn''t work.

I''m not expecting anyone to know the solution to this without sitting here and looking at it, but have you ever seen this kind of behaviour?

I''ve tried reboots etc.

Last night I checked into a hotel called "My Wits End" and I don''t think I''ll be checking out any time soon.

-Rd

推荐答案

好,我正式放弃尝试找出无关的代码行在做什么.

我已经解决了这个问题,或者尽管我一个人,但我还是被遗忘在正确执行此操作的角落.

现在,需要验证的文本框分别位于各自的ValidationGroup中.我在所有控件上都将验证组留为空白,因为我不介意是否同时对它们进行了验证.对于控件只能具有客户端验证的控件,它工作得很好.

这些货币文本框需要执行AutoPostback和服务器验证,除非我将其放入其自己的ValidationGroup中,否则它似乎不能很好地发挥作用.

为什么?我不知道.我不在乎吗?

现在,我的新问题是,如果我处于这些货币文本框之一中,然后单击保存"按钮,则会为文本框的Textchanged触发自动回发,但不会触发保存功能.

因此,我从AutoPost重新加载了页面,重新回到了文本框,看起来好像发生了什么事,但是除非再次点击save,否则什么都不会保存.

Gawd我讨厌ASP.Net

-Rd
OK, I officially give up trying to figure out what that unrelated line of code was doing.

I have worked around this problem, or perhaps I''ve been backed into a corner of doing it right despite myself.

The Text boxes that need validation are now each in their own ValidationGroup. I had left validation group blank on all controls because I didn''t mind if they were all validated together. It worked fine for controls can have client side only validation.

These currency text boxes need to do an AutoPostback and server validation and that doesn''t seem to play nice unless I put it in it''s own ValidationGroup.

Why? I don''t know. I don''t care?

Now my new problem is that if I''m in one of these currency text boxes and I Hit the save button, the AutoPostback fires for the Textchanged of the textbox, but the save functionality doesn''t fire.

So, I get a page reload from the AutoPost back on the textbox, making it look like something has happened, but unless you hit save again, nothing gets saved.

Gawd I hate ASP.Net

-Rd


这篇关于您不会相信我,但是这种情况正在发生.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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