|
|||||||||||||
07-12-2012 03:53 AM
I want to make control to show numeric value and its alarm status (Hi or Lo alarm). To make it simple, i derived my class from NumericEdit.
I make an object from that derived class and register it to autorefresh. At this point, the value updated.
Than I override RenderControl method with my own code. At this point, the value fail to update.
Any idea how to resolve this?
07-13-2012 01:01 PM
Hi taov,
Can you give us more detail on why you are using your own code for RenderControl and what you are doing differently? It sounds like you were getting the behavior you need before doing that, and there's now a bug in your method.
Thanks,
07-13-2012 07:25 PM
Hi KyleP, thanks for the reply.
Actually, I want to make a numeric control with alarm hi and lo indicator. The base NumericEdit control only render a textbox with numeric value inside. I want to add two boolean control (i.e. LED control) to display its alarm status. I also want to add engineering unit after its numeric value. That's why I override RenderControl.
07-16-2012 09:45 PM
Can you show a little bit more of what you're doing? It would be helpful to see the code for your RenderControl method.
Cheers,
07-29-2012 09:06 PM
Hi Kyle, sorry for late reply.
Here is my RenderControl code.
Could you tell which part is wrong? Or is there any way to make my control support AutoRefresh
protected override void RenderControl(System.Web.UI.HtmlTextWriter writer)
{
if (AlarmHiEnable)
{
///Create Hi Alarm Indicator
writer.AddStyleAttribute(HtmlTextWriterStyle.Margi nBottom, "2px");
writer.AddAttribute(HtmlTextWriterAttribute.Cellsp acing, "0px");
writer.AddAttribute(HtmlTextWriterAttribute.Cellpa dding, "0px");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.AddStyleAttribute(HtmlTextWriterStyle.Width , "23px");
writer.AddStyleAttribute(HtmlTextWriterStyle.Heigh t, "8px");
writer.AddStyleAttribute(HtmlTextWriterStyle.TextA lign, "center");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontF amily, this.Font.Name);
writer.AddStyleAttribute(HtmlTextWriterStyle.FontS ize, this.Font.Size.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundImage, "../../images/uji12.png");
if (AlarmHiStatus)
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundColor, this.ColorToHex(AlarmHiEnabledColor));
else
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundColor, this.ColorToHex(AlarmHiDisabledColor));
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write("H");
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
///Create table as numeric indicator with caption and engineering unit container
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundImage, "../../images/CustomIndicatorBackground.png");
writer.AddStyleAttribute("background-size", "100% 100%");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontF amily, this.Font.Name);
writer.AddStyleAttribute(HtmlTextWriterStyle.FontS ize, this.Font.Size.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Width, this.Width.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Cellsp acing, "5px");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
///create caption
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.AddAttribute(HtmlTextWriterAttribute.Colspa n, "2");
writer.AddStyleAttribute(HtmlTextWriterStyle.Color , ColorToHex(LabelColor));
writer.AddStyleAttribute(HtmlTextWriterStyle.TextA lign, LabelTextAlign);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(Label);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.RenderEndTag();
writer.RenderEndTag();
///create numeric indicator value
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundColor, "#cccccc");
writer.AddStyleAttribute(HtmlTextWriterStyle.Borde rColor, "black");
writer.AddStyleAttribute(HtmlTextWriterStyle.Borde rStyle, "solid");
writer.AddStyleAttribute(HtmlTextWriterStyle.Borde rWidth, "1px");
writer.AddStyleAttribute(HtmlTextWriterStyle.TextA lign, "right");
writer.AddStyleAttribute(HtmlTextWriterStyle.Paddi ngRight, "5px");
writer.AddStyleAttribute(HtmlTextWriterStyle.Margi nLeft, "5px");
writer.AddStyleAttribute(HtmlTextWriterStyle.Color , ColorToHex(ValueTextColor));
writer.AddStyleAttribute(HtmlTextWriterStyle.Width , "50px");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(Value);
writer.RenderEndTag();
writer.RenderEndTag();
///create engineering unit
writer.AddStyleAttribute(HtmlTextWriterStyle.Color , "white");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontF amily, "Arial");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontS ize, this.Font.Size.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(EngUnit);
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
if (AlarmLoEnable)
{
///create Lo Alarm Indicator
writer.AddStyleAttribute(HtmlTextWriterStyle.Margi nTop, "2px");
writer.AddAttribute(HtmlTextWriterAttribute.Cellsp acing, "0px");
writer.AddAttribute(HtmlTextWriterAttribute.Cellpa dding, "0px");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.AddStyleAttribute(HtmlTextWriterStyle.Width , "23px");
writer.AddStyleAttribute(HtmlTextWriterStyle.Heigh t, "8px");
writer.AddStyleAttribute(HtmlTextWriterStyle.TextA lign, "center");
writer.AddStyleAttribute(HtmlTextWriterStyle.FontF amily, this.Font.Name);
writer.AddStyleAttribute(HtmlTextWriterStyle.FontS ize, this.Font.Size.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundImage, "../../images/uji12.png");
if (AlarmLoStatus)
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundColor, this.ColorToHex(AlarmLoEnabledColor));
else
writer.AddStyleAttribute(HtmlTextWriterStyle.Backg roundColor, this.ColorToHex(AlarmLoDisabledColor));
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write("L");
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
}
07-30-2012 01:50 PM
taov,
In order to add AutoRefresh event support for non-Measurement Studio ASP.NET controls, it is necessary to define the IRefreshCallbackEventHandler Interface on that control.
This includes a RaiseRefreshCallbackEvent method that returns a RefreshCallbackResult that specifies the updates that are to be made on the client. It also defines an ID property that must return the ID of the server control.
More information can be found by opening the Measurement Studio Help and searching IRefreshCallbackEventHandler. The fourth result should be the Help Topic for IRefreshCallbackEventHandler Interface, which goes into more detail about the prototypes and namespaces for these methods.
08-02-2012 08:07 PM
Jared,
Thanks for the answer. I have implement IRefreshCallbackEventHandler in my custom control and that solved the problem. The value able to refresh.
But the second problem is, it only able to refresh the value property. I need the alarm status property also refreshed.
Does IRefreshCallbackEventHandler support multiple ID in single control?
08-03-2012 04:49 PM
Hey taov,
Could you give us some code on how you're implementing the IRefreshCallbackEventHandler?
Cheers,
My Profile | Privacy |
Legal |
Contact NI
© 2011 National Instruments Corporation. All rights reserved. | E-Mail this Page
|
||

E-Mail this Page