Hello,
I am trying to update a radtextbox inside a radwindow with the data received from a serial port where a scale is connected. The data is received on the serial port by a command issued from the scale.
Here is the setup of the radwindow and the radtextbox:
<telerik:RadWindow ID="RadWindowAddToSets" runat="server" Width="520px" Height="390px" Modal="True" CenterIfModal="false" Left="150" Top="20" OnLoad="RadWindowAddToSets_Load" Behaviors="Resize, Minimize, Pin, Maximize, Move, Reload"> <ContentTemplate> <asp:Panel ID="PanelAddToSets" runat="server"> <div style="height: 40px"> <telerik:RadTextBox ID="RadTextBoxWeight" runat="server" Width="300px" AutoPostBack="True" Height="20px" OnTextChanged="RadTextBoxWeight_TextChanged"> </telerik:RadTextBox> <telerik:RadButton ID="RadButtonAddToSetsOK" runat="server" OnClick="RadButtonAddToSetsOK_Click" Style="position: relative;" Text="OK" OnClientClicking="RadButtonAddToSetsOK_OnClientClicking"> </telerik:RadButton> <telerik:RadButton ID="RadButtonAddToSetsCancel" runat="server" Style="position: relative;" Text="Cancel" AutoPostBack="True" OnClientClicking="RadButtonAddToSetsCancel_OnClientClicking"> </telerik:RadButton> </div> </asp:Panel> </ContentTemplate> </telerik:RadWindow>
This is the code that is fired when the scale sends the data through the serial port. Here is where I tried to update the radtextbox directly. This seems to be working well as I see the RadTextBoxWeight.Text being populated during debugging.
private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs) { //string capturedSerial = ""; while (_serialPort.BytesToRead > 0) { RadTextBoxWeight.Text += string.Format("{0:X2} ", _serialPort.ReadByte()); }
I have tried a few things with the RadAjaxManager in attempts to display the data in the radtextbox, including using a hidden field and trying the ajaxRequestWithTarget method inside the add_load in JavaScript. I see the the alerts, but nothing else seems to happen.
Sys.Application.add_load(WindowSerialControl); function WindowSerialControl() { alert(form1.HiddenSerial.value); if (form1.HiddenSerial.value == "Capture") { alert("Inside Capture"); var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>"); ajaxManager.ajaxRequestWithTarget('<%= RadTextBoxWeight.UniqueID %>', ''); } }
I have tried multiple configurations in my testing with the radaajaxmanager. I currently have it like this:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadTextBoxWeight" UpdatePanelRenderMode="Inline" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadTextBoxWeight"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="PanelAddToSets" UpdatePanelRenderMode="Inline"/> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManager>
I'm sure I need to trigger an Ajax request somewhere/somehow, but am lost at this point.
Any help is appreciated.
G.