c# - Creating an AJAX Script Control -


Call me 'n00b', but I'm new to creating script controls. I want to make a simple control with 3 text boxes. I have one. CC file that looks like this:

  public class SmokingCalc: ScriptControl {public SmokingCalc (render () (html writer);} render void override safety (HtmlTextWriter writer) {costTextbox. RenderControl (author); base.Render (writer);} protected override IEnumerable & lt; Lipideskriptr & gt; GetScriptDescriptors () {ScriptControlDescriptor descriptor = New ScriptControlDescriptor ( "SmokingCalc.SmokingCalc", this.ClientID); yield returns descriptor;} / / Script reference protected override IEnumerable  GetScriptReferences () {yield returns new Script references ( "Dhumrpankar. Saikongkailsi. Js", it. GetType (). Assembly.FullName);} protected HtmlTextWriter htmlWriter; Protect text box costs textbox; safety textbox amount text box, protected textbox years textbox; protected Button submitButton;}}  

and I will render absolutely no idea that textbox Why not? I think I'm missing something ...

[ Edit] I'm getting the error That is, "Object is not set to an instance for reference object".

[Answered] I changed the file as follows, and it still works at a minimum

  public class SmokingCalc: ScriptControl {public SmokingCalc () {} protected override void CreateChildControls () {base.CreateChildControls (); CostTextbox.ID = "costTextbox"; AmountTextbox.ID = "Quantity Text Box"; YearsTextbox.id = "yearsTextbox"; SubmitButton.id = "Submit Button"; SubmitButton.Text = "submit"; Controls.Add (costTextbox); Controls.Add (amountTextbox); Controls.Add (yearsTextbox); Controls.Add (submitButton); } Protected Override IEnumerable & lt; Lipiduscriptor & gt; GetScriptDescriptors () {ScriptControlDescriptor descriptor = New ScriptControlDescriptor ("SmokingCalc.SmokingCalc", this.ClientID); Descriptor.AddProperty ("costTextboxID", costTextbox.ClientID); Descriptor.AddProperty ("amountTextboxID", amount text box. ClientID); Descriptor.AddProperty ("yearsTextboxID", amount text box. ClientID); Descriptor.AddProperty ("submitButtonID", submitButton.ClientID); Yield returns descriptor; } // Script Reference Protected Override IEnumerable & lt; ScriptReference & gt; GetScriptReferences () Returns the new script reference ("Smoker. Psychogcalci.js", it. GetType (). Assembly.FullName); } Cost of Secure Text Box Text Box = New Text Box (); Protected text box amount Textbox = new text box (); Protected text box year text box = new text box (); Protected Button submitButton = New Button (); }  

Did you try?:

  Public Class Smoking: Protected Override Zero CreateChildControls (Add this .control (costTextbox);} Protected override IEnumerable & lt; lipidiscriptor & gt; GetScriptDescriptors () {ScriptControlDescriptor descriptor = New ScriptControlDescriptor ("SmokingCalc.ComingCalc", this .ClientID); yield returns descriptor;} // script references protected override IEnumerable & lt; ScriptReference & gt; GetScriptReferences () {yield return new script Snder Protected Text Box: Text Box = New Text Box (); Text Message - Text Box (Text Box) = New Text Box ("Smoking: Cycloglassy .Js", GetType (). Assembly.FullName);} Protected HtmlTextWriter HTMLWriter; ); Protected text box year text box = new text box (); preserve button submitButton = new button ();}  

Comments