1

I posed a similar question about this before, and it would seem based on the answers that I received that I can't expect to be able to rely on a radio button's CheckedChanged event to fire in real time.

Am I really stuck with waiting until the form is submitted before that event fires, or can I add client-side (jQuery) code to handle it? If so, how? How can I mix jQuery client code in with my C# server code in a Sharepoint (2010) project?

What I want to be able to do now is to dynamically alter the controls on the page based on decisions made by the user (if they select this radio button, a particular textbox has this set of properties applied, and if the other radio button, a different set of properties). Is this possible?

UPDATE

I create controls and add CheckedChanged events to them like so:

rbUSCitizenOrPermResY = new RadioButton
{
    CssClass = "finaff-webform-field-input"//,
    //CheckedChanged += new EventHandler(rbUSCitizenOrPermResY_Changed) <= the name 'CheckedChanged' does not exist in the current context
};
rbUSCitizenOrPermResY.CheckedChanged += new EventHandler(rbUSCitizenOrPermResY_Changed);
cellRadioButton1_1.Controls.Add(rbUSCitizenOrPermResY);

The Save button is like so:

Button btnSave = new Button();
btnSave.Text = "Save";
btnSave.Click += new EventHandler(btnSave_Click);
this.Controls.Add(btnSave);


    . . .

private void btnSave_Click(object sender, EventArgs e)
{
    LiteralControl message = null;
    try
    {
        message = new LiteralControl();
        Controls.Add(message);
        ConditionallyCreateList();
        SaveInputToList();
        List<ListColumns> listOfListItems = ReadFromList();
        GeneratePDF(listOfListItems);
        message.Text = "Saving the data and converting it to a PDF has been successful";
    }
    catch (Exception ex)
    {
        message.Text = String.Format("Exception occurred: {0}", ex.Message);
    }
}

What is special about the Save button that it fires immediatley when clicked, yet the CheckedChanged event of a RadioButton does not fire (immediately)?

UPDATE 2

This says, "...UpdatePanel control ... by default, this control does not work with these standard SharePoint components..."

So it sounds like using it is trying to shoehorn a lumberjack's foot into a baby booty.

Then what is the preferred method for getting Sharepoint components to update?

UPDATE 3

Theoretically, it seems maybe this will work:

UpdatePanel up = new UpdatePanel();
up.Controls.Add(dynamicTable); // or just add the radio buttons, rather than the entire HtmlTable?
ScriptManager sm = new ScriptManager();
sm.EnablePartialRendering = true;

...I'll find out, I reckon...

Community
  • 1
  • 1
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • This *might* be a good time to read about the [Update Panel](https://msdn.microsoft.com/en-us/library/bb399001%28v=vs.140%29.aspx). I'm **not** a fan of it, but it would serve this requirement well. It also requires **no** JavaScript. – Der Kommissar May 28 '15 at 16:22
  • I'm about to read that, but first: why are you *not* a fan of it? On a scale of -1 to 17, what is its PITA factor (17 being the biggest Pain In The Ankle)? – B. Clay Shannon-B. Crow Raven May 28 '15 at 16:26
  • The answer to that question depends on **who** the `PITA` factor applies to. For developers, it's *extremely* easy, probably a 2-3 on that scale. For users, it does a partial page-refresh. So it's a bit unsightly. It also causes the browser to **lose** any input focus on any fields affected by the refresh. (It refreshes the portion of the page in the `UpdatePanel`, so probably a 12-14.) – Der Kommissar May 28 '15 at 16:47
  • All my controls are dynamically created, so if I go this route, I guess I'll have to add the ScriptManager(Proxy) and UpdatePanel programatically first... I create my controls programmatically because I'm using a WebPart editor to allow the user to determine which sections of the page (and thus which controls) are seen/created. – B. Clay Shannon-B. Crow Raven May 28 '15 at 17:14

0 Answers0