[CLOSED] Adding Checkbox items to checkbox group during a postback?

Page 2 of 2 FirstFirst 12
  1. #11

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    You defined AjaxMethod in the OptionsQuestion user control. This control is inaccesable when you call ajax method (because it is not loaded, you loaded that user control once only). Therefore ScriptManager cannot find that method. Move that AjaxMethod to the Page or another user control which always presented on the page
  2. #12

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    I moved the "GetMarks" ajax method to first SectionEvaluator (which always there in default.aspx) and also tried to move that to page (default.aspx)

    But scriptmanager is expecting the method only from OptionsQuestion.ascx user control only.

    It is displaying an error "Coolite.AjaxMethods.ucSectionEvaluator_ctl09.GetM arks' is null or not an object.

    Thanks in advance.

    Regards,
    Gopal.
  3. #13

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    Because you use #{AjaxMethods} in the user control (it is mean current context but your AjaxMethod in the onther context)
    If AjaxMethod in the Page then use
    ...Check.Handler = "Coolite.AjaxMethods.GetMarks(...);";

    If AjaxMethod in the SectionEvaluator then
    ...Check.Handler = "Coolite.AjaxMethods." + here_is_ClientID_of_the_ucSectionEvaluator + ".GetMarks(...);";
  4. #14

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    Or add the following attribute for user control which conatins ajax method
    [AjaxMethodProxyID(IDMode = AjaxMethodProxyIDMode.Alias, Alias = "UC")]

    and call that AjaxMethod as
    "Coolite.AjaxMethods.UC.GetMarks(...);"

    See
    https://examples1.ext.net/#/Events/AjaxMethods/ID_Mode/
  5. #15

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    Thank you very much :-).

    It worked for me.

    Regards,
    Gopal.
  6. #16

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    I ran into other problems when I tried to add dynamic controls during every post back.

    Please look into these.

    1) Loosing Selections in the first postback.

    I am creating control structure during every post back.

    But i am loosing the selections of check box items (coolite) for the first post back where as if I use asp.net checkbox list it is preserving the selections and showing the weightage.

    Please see attached test solution.

    Reproduction steps:

    1. Run Default.aspx page.
    2. It created both Coolite Check Box group items and asp.net checkbox listItems.
    3. Select the "Option 1" (which is marked as correct answer) from both coolite checkbox list and as well as aspnet checkbox list.
    4. Click on submit.
    5. In the submit code-behind i am calling ValidateData method for each user control i am creating by finding them in the window body container controls recustively.
    5. You can observe that, for the correct answer, asp.net text box displaying the assigned weightage of the question, where as coolite textbox not. :(

    6. If I reselect the "option 1" again in coolite checkbox and clicking on submit button (second time), then coolite textfield showing the assigned value.

    Could you please look into this issue?

    2) To get the selection optionId i am assigning that value to custom attribute of coolite checkbox (where as in asp.net listtem value property can preserve this) and retrieving it again when validating.

    please check this also.

    Thanks in advance.

    Regards,
    Gopal.
  7. #17

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    1. You don't persist tyhe same IDs for controls between posstback. You have diffrent logic during initial page load and postback: during initial page load you call LoadData in the user controls but during postbacks you don't. Byt LoadData changes Controls collections. Therefore dynamic IDs (you don't provide own IDs therefore ASP.NET generates own IDs) are different during initial page load and postabck. This is the reason why control cannot retrieve own state on the server side


    2. I am not sure that clear understood your swcond issue. Coolite controls don't support Attributes collection (because Coolite toolkit produces javascript instead Html). Please provide more details why is it required and what are try to achieve?
  8. #18

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    Sorry! I didn't understand your explanation. I am calling LoadData of ucSectionEvaluator in Default.aspx page Init event handler "everytime".

    Are coolite controls' state management is different from asp.net controls?

    As and when the page is loading, Page_Init is called and ucSectionEvaluator will be assigned with details and loadData method is called every time.

    During "post back also" the "Page_Init" method is called. Here I am not using dynamic ids generated by the ASP.NET. I am getting the controls based on their types and validation method is called in the post back.

    So, I think here the generation of dynamic control ids are not so important. Only the state management is important.

    You can observe that by clicking submit button for the first time also asp.net control are preserving the controls data and question weightage is calculated. I am getting the problem with coolite controls only.


    If I am missing anything here please let me know.

    Regards,
    Gopal.
  9. #19

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    Just compare IDs of the Coolite checkboxes during initial page load and after postback. They are different.

    Here I am not using dynamic ids generated by the ASP.NET.
    If you don't provide own ID then ASP.NET set ID dynamically because control should always has ID

    As
    and when the page is loading, Page_Init is called and
    ucSectionEvaluator will be assigned with details and loadData method is
    called every time.
    Yes, LoadData of the SectionEvuator control calls LoadData of other controls. But during initial page load the LoadData of the OptionsQuestion control is called twice (during postback once only). It is change logic if compare initial page load and postback therefore dynamic IDs are different. Just always set explicit IDs for controls

    So, I think here the generation of dynamic control ids are not so important. Only the state management is important.
    If IDs are different than state management (including load data from Request.Form to the controls properties in the LoadPostData) cannot be performed correctly

    For example if I set in the OptionsQuestions class LoadData
    chkBox.ID = cbgOptionsQuestion.ID + "_" + qo.OptionId.ToString(); // just ensure that is unique ID
    then it is fix your problem. And I recomend to avoid that twice calling of the LoadData


  10. #20

    RE: [CLOSED] Adding Checkbox items to checkbox group during a postback?

    Hi,

    You are genius! :-)

    It worked. I actually implemented the unique ids in one of my previous projects when I was rendering the user controls in a asp.net wizard control. Thank you for pointing out that.

    I think we can mark this as solved.

    Thanks a lot.

    Regards,
    Gopal.
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Checkbox with group command.
    By hendry_agust in forum 1.x Help
    Replies: 1
    Last Post: Jun 13, 2012, 9:28 PM
  2. About checkBox group
    By Egale in forum 1.x Help
    Replies: 0
    Last Post: May 05, 2011, 5:32 AM
  3. [CLOSED] [1.0] Dynamically load checkbox in Checkbox Group
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 14, 2010, 5:05 PM
  4. [CLOSED] Adding Item to Checkbox group by Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 31, 2010, 7:17 PM
  5. Checkbox in Group Command
    By hendry_agust in forum 1.x Help
    Replies: 0
    Last Post: May 04, 2010, 11:06 PM

Tags for this Thread

Posting Permissions