Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2700
WebCurrencyEditor created server side
posted

Hi,

I am creating a table server side and 3 of the cells on each row contain a WebCurrencyEditor and this seems to be causing problems.  I am creating the controls in a loop using the following code :-

TableCell responsibilityCell = new TableCell();
WebCurrencyEditor wceResponsibility = new WebCurrencyEditor();
wceResponsibility.ID = table.ID + "_row_" + table.Rows.Count.ToString() + "_responsibility_" + lblWeekNumber.Text;
wceResponsibility.MinDecimalPlaces = 0;
wceResponsibility.MaxDecimalPlaces = 2;
wceResponsibility.Buttons.SpinButtonsDisplay = ButtonDisplay.None;
wceResponsibility.Width = 50;
wceResponsibility.ValueDouble = (responsibilitySheet == null) ? 0 : responsibilitySheet.Cost;
wceResponsibility.ValueChanged += new TextEditorValueChangedEventHandler(wceResponsibility_ValueChanged);
responsibilityCell.Controls.Add(wceResponsibility);
responsibilityCell.BackColor = ColorTranslator.FromHtml("#70C1D8");
row.Cells.Add(responsibilityCell);

This should ensure that the IDs are unique across rows and I expected the Value Changed event to be called if I type a value into the box.  This does not happen.  I cannot see how to enable auto postback for the control (assuming that this is not the default).  You seem to be able to do this client side but not server side and as the table is dynamically created it would be difficult client side really.

I also seem to get 'unknown' errors when I refresh the screen but cannot track down what is causing these.  Is it possible to create these controls server side and get them to be notified as and when the value is changed?

Parents
No Data
Reply
  • 24497
    posted

    Hi cmdrew,

    The server ValueChanged event is raised when after any postback value in editor was modified. In order to trigger postback when value in editor was changed (on lost focus), application should use following:

    If application needs to postback before blur, for example, when user entered specific value, then application should process ClientEvents.TextChanged="handlerName" and trigger postback from client. If second parameter in __doPostBack will match with any AutoPostBackFlags, then corresponding server event will called.
    Example,

    <script type="text/javascript">
     function WebCurrencyEditor1_TextChanged(sender, eventArgs)
    {
       if(eventArgs.get_text().length > 2)
       
    __doPostBack(sender.get_uniqueID(), 'ValueChanged');
    }
    </script>

Children