FAQ Database Discussion Community


Why is this jQuery running — but not working — on my page, although it works in jsfiddle?

jquery,web-parts,document-ready,ascx,onkeyup
I want to restrict the entries in a text element to numeric only. I found some code for that that works in the jsfiddle, which is referenced from here ...but on my page (Webpart) / *.ascx file, it does not. I see the alert every time I mash a key,...

How can I add jQuery to a WebPart (to respond to certain events on the WebPart)?

c#,jquery,sharepoint-2010,web-parts
I started down the path of adding an UpdatePanel to my Sharepoint page so that I can respond to events that take place (such as the checking of checkboxes and mashing of radio buttons, etc.). That so far has, however, been wrought with frustration and all that rot, as can...

How can I reduce the width of an HtmlTableCell or otherwise join together two controls in an HtmlTableRow?

c#,html,asp.net,sharepoint-2010,web-parts
I am dynamically creating several HtmlTableRows and adding cells to them, like so: HtmlTable dynamicTable = new HtmlTable(); . . . // Create row 6 var row6 = new HtmlTableRow(); var cellLitCtrl_6 = new HtmlTableCell(); var cellTxtbx_6 = new HtmlTableCell(); row6.Cells.Add(cellLitCtrl_6); row6.Cells.Add(cellTxtbx_6); var mailStopStr = new Label { CssClass =...

Why is this jQuery not working on my Sharepoint page?

jquery,html,checkbox,sharepoint-2010,web-parts
I have this code at the bottom of my Sharepoint WebPart's .ascx file: <script> $(document).ready(function () { alert("The ready function has been reached"); $('#ckbxEmp').on("change", function () { if ($('#ckbxEmp').prop("checked")) { alert("Checked"); } else { alert("Not checked"); } }); }); </script> On running the WebPart (opening a page that has the...

How can I reduce the amount of vertical space between lines of text using CSS?

css,sharepoint-2010,web-parts
The "obvious" answer is to use the line-height CSS rule, but this code (where I do use that): private void GenerateSection7() { var headerFirstPart = new Label { CssClass = "finaff-webform-field-label", Text = "<h2><strong>Section 7: Submit Information </strong></h2>" }; headerFirstPart.Style.Add("display", "inline-block"); headerFirstPart.Style.Add("white-space", "pre"); headerFirstPart.Style.Add("line-height", "20%"); var headerSecondPart = new Label...

How can I respond to a RadioButton's change event with jQuery on a SharePoint WebPart?

jquery,sharepoint-2010,web-parts,document-ready
I'm getting close; after floundering around on an isolated promontory and sending forth filament, filament, filament out of myself (as recorded here), I added this to the end of the WebPage's *.ascx file (after the <%@ Assembly, <%@ Register, <%@ Import, and <%@ Control jazz, as well as an <script>...

Can I create javascript in SP web part to post to Yammer group, not in an app?

web-parts,yammer
I've been asked to create a simple web part that will create a post in a specific yammer group. All the code samples I have found involve registering an app. Is an app the only way?...

Can REST-like URLs be passed/recognized in sharepoint 2010?

c#,rest,sharepoint-2010,web-parts,dynamic-usercontrols
I know that REST can be used to query list data in SharePoint (even in SP 2010). What I need, though, is a REST-like (not necessarily literally "canonical" REST) way to generate a Web Page. Here is my scenario in more detail: I dynamically create controls via C# when the...

Why is OnPreRender being called over and over again?

asp.net,sharepoint-2010,web-parts,pageload,webpartpage
In my Sharepoint 2010 WebPart, I have this code: protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (this.dpsvisWebPart != null && this.dpsvisWebPart.CustomTitleProp != null) { lbl_Title.Text = String.Format("<h1>{0}</h1>", this.dpsvisWebPart.CustomTitleProp.ToString()); if (this.dpsvisWebPart.CheckboxGenSection1) { GenerateSection1(); } if (this.dpsvisWebPart.CheckboxGenSection2) { GenerateSection2(); } if (this.dpsvisWebPart.CheckboxGenSection3) { GenerateSection3(); } if...

Why does my Sharepoint WebPart deploy (nominally), but is still not available for adding to a page/form?

sharepoint,sharepoint-2010,web-parts,webpartpage
I've created and "deployed" my latest Web Part (Visual Studio grins from ear-to-ear, and tells me, "Deploy succeeded"). But when I go to our Sharepoint site, and my "sandbox" page, and Edit it, I do not see the WebPart. As the Elements file shows, it should be available from the...