ASP.net Ajax:linkbutton的回发问题

时间:2022-08-24 03:38:15

I have a "Yes" linkbutton that trigger a popup (ModalPopUpExtender) The popup contain a web user control that allow the user to do some data entry if they click on "Yes" linkbutton.

我有一个触发弹出窗口的“是”链接按钮(ModalPopUpExtender)弹出窗口包含一个Web用户控件,允许用户在单击“是”链接按钮时进行一些数据输入。

The Yes linkbutton is inside a asp panel with another linkbutton called "No" that is hidden and will become visible when the user click on the text box. this text box is the target of the dropdownextender. Both Yes and No linkbutton is trigger for the text box that is inside a UpdatePanel and will update it's text value to either Y or N.

“是”链接按钮位于asp面板中,另一个名为“否”的链接按钮被隐藏,当用户单击文本框时将变为可见。此文本框是dropdownextender的目标。 “是”和“否”按钮都是触发UpdatePanel内部的文本框,并将其文本值更新为Y或N.

If i click on the No linkbutton, it will trigger the code behind event and update the text box value but not with Yes linkbutton. It will not trigger its event (OnClick) (code behind). It will only trigger the modal popup extender therefore i can't update the text box value to Y with Yes linkbutton.

如果我单击No linkbutton,它将触发事件后面的代码并更新文本框值,但不是Yes linkbutton。它不会触发它的事件(OnClick)(后面的代码)。它只会触发模态弹出扩展器,因此我无法使用是链接按钮将文本框值更新为Y.

I can change the text box value via javascript but when i click on Update button to update the database. the text box value is still not change. i guess the javascript only change the textbox's html value but not the value inside the viewstate.

我可以通过javascript更改文本框值,但是当我单击“更新”按钮更新数据库时。文本框值仍未更改。我想javascript只会更改文本框的html值,而不会更改viewstate中的值。

two questions:

  1. Can the control trigger an event (run code behind code) if it is being use as targetcontrol in ajax framework control? Am i missing something?

    如果在ajax框架控件中将控件用作targetcontrol,控件是否可以触发事件(在代码后面运行代码)?我错过了什么吗?

  2. How do you change the value of a control via javascript? Not just on the surface (html) but also in the viewstate so when a update occurred the actual value of control such as textbox's .text value is changed.

    你如何通过javascript更改控件的值?不仅在表面(html)而且在视图状态中,因此当更新发生时,控件的实际值(例如textbox的.text值)会发生变化。

3 个解决方案

#1


I am sorta confused by your question...but I remember trying to do similar stuff. Whenever interacting with ASP and java this page was very helpful:

我对你的问题感到困惑......但我记得试着做类似的事情。每当与ASP和java交互时,这个页面都非常有用:

http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager_methods.aspx

#2


If both Yes and No LinkButtons are inside of an UpdatePanel, why not just have Yes button trigger an async postback, change TextBox value, then call Show() method on ModalPopup from code behind?

如果Yes和No LinkBut​​tons都在UpdatePanel中,为什么不只是让Yes按钮触发异步回发,更改TextBox值,然后从代码后面调用ModalPopup上的Show()方法?

I'm not sure if i'm understanding your question fully... Some code might help us to understand your situation better.

我不确定我是否完全理解你的问题......有些代码可能会帮助我们更好地了解你的情况。

#3


all. I kinda cheat a little and use Hidden Field. I use javascript to alter the hidden field value thus it get the result that i want.

所有。我有点作弊并使用隐藏场。我使用javascript来改变隐藏的字段值,从而得到我想要的结果。

I hope this is helpful for someone with similar problem.

我希望这对有类似问题的人有帮助。

Jack

#1


I am sorta confused by your question...but I remember trying to do similar stuff. Whenever interacting with ASP and java this page was very helpful:

我对你的问题感到困惑......但我记得试着做类似的事情。每当与ASP和java交互时,这个页面都非常有用:

http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager_methods.aspx

#2


If both Yes and No LinkButtons are inside of an UpdatePanel, why not just have Yes button trigger an async postback, change TextBox value, then call Show() method on ModalPopup from code behind?

如果Yes和No LinkBut​​tons都在UpdatePanel中,为什么不只是让Yes按钮触发异步回发,更改TextBox值,然后从代码后面调用ModalPopup上的Show()方法?

I'm not sure if i'm understanding your question fully... Some code might help us to understand your situation better.

我不确定我是否完全理解你的问题......有些代码可能会帮助我们更好地了解你的情况。

#3


all. I kinda cheat a little and use Hidden Field. I use javascript to alter the hidden field value thus it get the result that i want.

所有。我有点作弊并使用隐藏场。我使用javascript来改变隐藏的字段值,从而得到我想要的结果。

I hope this is helpful for someone with similar problem.

我希望这对有类似问题的人有帮助。

Jack