I am new to creating AJAX script controls, so I need your help. I have
a simple control I want to make, that has 3 textboxes and a button.
The reason I am using AJAX is because I want to present a popup and
allow theming of the control. I also want cool loading animations and
such, without postbacks. So, I have a control that I started to make,
and I can't figure it out. The textboxes don't even show up! Tell me
the direction I need to go in because it is apparent to me that Script
Controls are MUCH different than Server Controls.

Heres the code I have so far.

    public class SmokingCalc : ScriptControl
    {
        public SmokingCalc()
        {
            Render(htmlWriter);
        }
        protected override void Render(HtmlTextWriter writer)
        {
            costTextbox.RenderControl(writer);
            base.Render(writer);
        }
        protected override IEnumerable<ScriptDescriptor>
                GetScriptDescriptors()
        {
            ScriptControlDescriptor descriptor = new
ScriptControlDescriptor("SmokingCalc.SmokingCalc", this.ClientID);
            yield return descriptor;
        }

        // Generate the script reference
        protected override IEnumerable<ScriptReference>
                GetScriptReferences()
        {
            yield return new ScriptReference
("SmokingCalc.SmokingCalc.js", this.GetType().Assembly.FullName);
        }

        protected HtmlTextWriter htmlWriter;
        protected TextBox costTextbox;
        protected TextBox amountTextbox;
        protected TextBox yearsTextbox;
        protected Button submitButton;
    }
}

As you can see, my textboxes and button are created, and the
HtmlWriter is there. I override Render, and try to render the
costTextbox with the HtmlWriter passed in during default construction.

Help me out, because I am lost.

Reply via email to