Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

(I asked a similar question, but decided to repost it with clearer wording.)

I have a SP 2010 list for which I have created a NewForm.aspx form using SharePoint Designer. I have discovered (the hard way) that you cannot add code directly to the NewForm.aspx page.

But, if I want to do things such as conditionally change the filtering for queries used to populate dropdown menus on the form, what is the best way to go about this? I thought the answer was to create a code-behind page, but I'm seeing people say that isn't the SharePoint way. Okay, so what is the SharePoint way to go about this? How do I go about hitting this NewForm.aspx nail with a C# hammer?

I am not looking for a "use jQuery on the client side" answer, and here's why: One of the tasks I'm trying to accomplish is to intelligently filter a query list before it is ever delivered to the client. Why? So I can avoid populating an HTML select menu with 700 options, only to strip away 695 of them with jQuery.

I really am looking for how do I go about using C# to work on NewForm.aspx.

share|improve this question
    
Don't forget that if you log in you will be able to edit your question directly, and also comment on answers (rather than respond in the question). –  SPDoctor Sep 24 '12 at 16:47
    
Why on earth would you populate your select with all 700 options? You can filter in any of the calls you make with CSOM in JavaScript or using SPServices. –  Robert Kaucher Sep 24 '12 at 17:57

1 Answer 1

up vote 6 down vote accepted

For almost all UI interactions in SharePoint 2010 I use jQuery with either the Client Side Object Model or SPServices. In my opinion this gives me much greater control and richer interactions which users have come to expect.

share|improve this answer
    
While I still dont' have a solution to my misery, it does appear the answer to my problem is to forget server-side code, and go with the "SPServices or CSOM" answer. I'll focus my efforts on SPServices as I'm more comfortable with jQuery. –  Alan M Sep 24 '12 at 22:25
    
I thought that I had mentioned this in my answer but I obviously did not. A NewForm.aspx is still just an ASP.NET page and subject to the same rules. You an add a code behind or do in-line C# as well. But I think for most things JavaScript just makes my life easier for forms. –  Robert Kaucher Feb 15 at 3:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.