2011-11-22 32 views
0

我正在創建一個Web用戶控件,在AspxGridView列上顯示警報(刪除/編輯),單擊服務器端事件。 例如:DevExpress Web用戶控件 - 創建MessageBox,ConfirmBox?

刪除了行被禁用,則如果像ASP網格視圖時刪除命令會火,那麼在刪除該刪除節目消息是不允許/確認之前刪除,因爲我們在Windows應用程序做..

原因:

To reduce the database hit for checking that user allowed to delete/ Edit 
particular record. 

I do not want to check thousand of rows to disable them OnHtmlRowCreated Event 
of AspxGridView 

我已從這codeproject ajax enabled confirm box/messagebox採納了一個想法。 這裏使用的是ajax用戶控件。它使用更新面板和Molalpoputentender控件來創建此用戶控件。

它提供了這些功能。

The MessageBox should have a simple usage. We should show the message with such a single line of code. 
The MessageBox should be modal. I mean, a user should not be able to do any other operation while the message is open. 
The MessageBox should support multiple messages. Multiple messages may be shown through one postback. 
The MessageBox should have a different appearance according to the type of the message, whether it is an error message or just an information message. 
The MessageBox should have confirmation functionality. 
The MessageBox should be AJAX ready. 

優點:這個用戶控制可以在服務器側被調用,並且可以在AJAX控件的服務器側的功能進行更新。

我不想在我的項目中包含Ajax庫。所以,我做了使用這個我的解決方案如下:

Replaced Update Panel with CallbackPanel control 
Replaced PopupExtender with DevExpress PopupControl 
Add all content of the PopupExtender target panel's control to PopupControl content Collection 

問題: DevExpress的控制沒有更新方法如AJAX控件和所有這些callbackpanel和popupcontrol工作在回調居多。

這是用戶控件的PreRender事件。用戶控件在回發中更新的位置。我想在gridview OnDeleting事件上更新這個事件

protected override void OnPreRender(EventArgs e) {0}

 if (btnOK.Visible == false) 
      mpeMsg.OkControlID = "btnD2"; 
     else 
      mpeMsg.OkControlID = "btnOK"; 

     if (Messages.Count > 0) 
     { 
      btnOK.Focus(); 
      grvMsg.DataSource = Messages; 
      grvMsg.DataBind(); 

      mpeMsg.Show(); /// Show AspxPopupControl like as like modalpopupExtender 
      udpMsj.Update(); // I want to update CallbackPanel like this 

     } 
     else 
     { 
      grvMsg.DataBind(); 
      udpMsj.Update(); /// I want to update CallbackPanel like this 
     } 
     if (this.Parent.GetType() == typeof(UpdatePanel)) 
     { 
      UpdatePanel containerUpdatepanel = this.Parent as UpdatePanel; 

      containerUpdatepanel.Update(); 
     } 
    } 

有實現這個功能就像另一個頁面上創建控件,並加載HTML渲染到 popupcontrol另一種方式。但這是Callback中的客戶端功能。

我知道這些控件的回調函數,但我希望這個用戶控件自動化,因爲Ajax控件與Windows控件一樣,但是在DevExpress中,沒有辦法使用提供服務器端功能的DevExpress控件來實現。

回答

2

利用http://www.devexpress.com/example=E1120方法爲出發點。此選項介紹如何使用ASPxPopupControl(DevExpress ASP.NET產品系列的彈出窗口)來實現此目的。

我相信可以將所需的解決方案與使用DevExpress產品相結合。如果您有任何困難,請DX支持人員在這方面爲您提供幫助。

+0

謝謝你的建議@Mikhail ..我很久以前看過這個例子。我知道這件事。其實我想創建一個通用的用戶控件,使用這些控件,它像ajax控件一樣工作。我不想使用任何技巧,所以我把這個問題放在這裏。再次感謝。 –

+0

>>我不想使用任何技巧。<<哪一個? – Mikhail

+0

如果我按照例子做,那麼它只會在客戶端工作。 在示例中,usercontrol是單獨的實體,並且您將該用戶控件放置在PopupControl上。我已經在鏈接中指定了我想在OnUpdating事件上顯示控制服務器端。簡單地說,如果我初始化該控件,那麼它將顯示PopMessage/ConfirmBox。這是可能的使用Ajax和正常工作。但我希望通過'callbackPanel'和'PopupControl'..但是所有這些都是在客戶端啓動的。 Popup.ShowOnPageLoad不符合我的要求,因爲您知道回調不會觸發preRender事件。 –