ASP.net Ajax:linkbutton的回發問題

[英]ASP.net Ajax: postback problem with linkbutton


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


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/01/30/9ec5685f10c2df386f67f3b0d87fde4f.html



 
  © 2014-2022 ITdaan.com 联系我们: