using FastReport.Dialog;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FastReport.Web
{
    public partial class WebReport : WebControl, INamingContainer
    {

        private void RadioButtonClick(RadioButtonControl rb, string data)
        {
            bool oldValue = rb.Checked;
            rb.Checked = data == "true";
            rb.FilterData();
            if (oldValue != rb.Checked)
                rb.OnClick(null);
        }

        private string GetRadioButtonHtml(RadioButtonControl control)
        {
            string id = Prop.ControlID + control.Name;
            return string.Format("<span class=\"{0}\" style=\"{1}\"><input style=\"vertical-align:middle;width:10px;border:none;padding:0;margin:0 5px 0 0;\" type=\"radio\" name=\"{2}\" value=\"{3}\" onclick=\"{4}\" id=\"{5}\" {6} {7}/><label style=\"{9}\" for=\"{5}\">{8}</label></span>",
                // class
                "",
                // style
                GetRadioButtonStyle(control),
                // name
                control.Name,
                // value
                control.Text,
                // onclick
                GetEvent("onclick", control, string.Format("document.getElementById('{0}').checked", id)),
                // title
                id,
                control.Checked ? "checked" : "",
                control.Enabled ? "" : "disabled",
                control.Text,
                GetControlFont(control.Font)
                );
        }

        private string GetRadioButtonStyle(RadioButtonControl control)
        {
            return GetStandardStyle(control);
        }

    }
}
