Issue with Kendo Asp.Net MVC Grid Popup template Add/Update record - asp.net

I'm using Kendo Asp.Net MVC Grid Control.
I'm facing a problem while adding new record.
1) I'm Using editable.Mode(GridEditMode.PopUp)
2) I'v created a template for new record.
3) In Template I'v Editor Control (Which allow enter text with HTLM tags like Paragraph , underline, bold letters, etc).
Up to here every thing good. :-)
Here is my problem:
When I enter text without adding HTML tags the New record is adding and Updating in the grid.
But, When I enter any HTML tags. It is not adding new record and updating grid.
I have added .Encoded(false) for Grid column and Editor Control(In Template)
Thanks in help.

Most probably, the HTML value is posted non-encoded and triggers the ASP.NET request validation. If you check the browser console, you may see the infamous potentially dangerous request.form value was detected from the client message. Either disable security validation, or set the AllowHtml attribute on the model field that will receive the HTML string. Here is some more information about request validation in ASP.NET.

Related

Sitecore - Webforms for Marketers 2.3 - Inserting a new form into a page

I'm trying to insert a new form I created in Webforms for Marketers 2.3. I go to the page I want to insert the form on, presentation tab, form, Insert. I select the form I created but then get a message - "There are no allowed placeholders in order to insert a new form".
I then went to Layout-Placeholder Settings-Content and added Layout-Renderings-Modules-Webforms for Marketeres - Form.
No success.
I've also tried adding the form while it was and was not in the Webforms for Marketers restricting placeholders settings.
No success.
So, anyone know what I'm missing? Do I need to add a specific sitecore placeholder in the sublayout to hold the form?
To expand upon Zach's answer.
I had not been binding the placeholder settings to the page correctly. To do this I went to the Presentation tab and hit details.
I then went to the placeholder settings, and added a new entry here.
Make sure to enter the correct place holder where the form will be entered. Then go and add the form on the page. Once you choose your form and have added the placeholder correctly, it should show up here. (This was my original problem).
You need to set up which placeholders a form may be added to using the Restricted Placeholders window accessible from the Sitecore Desktop.
Steps
First, open the sitecore desktop and go to All Applications -> Web Forms for Marketers -> Restricting Placeholders:
Next, use the resulting window to configure the placeholders to which forms may be added. At least one of the selected placeholders must be present for you to add a form to the item.
I hope this helps. Good luck! :)
There is another edge case where this dialog may fail to display your available WFFM placeholders.
If you have the SSL Redirector module installed, and the form page in HTTPS mode, the dialog will fail to display the list of placeholders.
The solution is to modify the SSL Redirector to only perform redirection when Context.PageMode.IsNormal is true, and the current site name != "shell".

ASP.Net 4.0 with TinyMCE and XML Encoding re-encodes Content on Postback

i have a ASP.NET 4.0 based CMS, where i use the TinyMCE (3.4) via jQuery to edit one Textbox.
In addition to this i have several other textboxes.
There is also another DropDown List on the Page, which controls the Contenttype.
This Control has AutoPostback enabled and sets the visibility on the textboxes regarding the selectes item.
As i want to keep the Postback Validation on i have configured the TinyXML to use xml for the content serialisation (encoding: "xml").
Now i have the problem, when a postback from e.g. the DropDown List occures, the re-encodes the content.
Init: "Hallo"
1st Postback: "<p>Hallo</p>"
2nd Postback: "<p><p>Hallo</p></p>"
i have enabled the original textarea via css and this seems to be a problem of the TinyMCS's Save method.
Does anybody have a solution, how to fix this issue maybe with a custom save_callback on the TinyMCE?
Could it be that the data is being reloaded into the tinymce window after it is saved?
When I encountered this before in TinyMCE/WebForms, it was easily fixed by decoding the data before populating the form field and after postbacks:
TextAreaID.Text = Server.HtmlDecode("<p>hello</p>");
I have just had a similar problem with Tinymce and Asp.NET MVC. In my case what was happening was:
The form is submitted and tinymce html encodes the content (I am using the encoding: 'xml' option)
In my server side post action, I html decode the tags I want to allow (simplified example: decodedHtml = model.HtmlContent.Replace("<p>", "<p>")). Then after saving to the database and etc, I update model.HtmlContent with the decoded html (model.HtmlContent = decodedHtml)
but at this point the tinymce editor was showing the encoded html, i.e. <p>test</p> instead of <p>test</p> , even though I did model.HtmlContent = decodedHtml in my post action. What actually happens is asp.net ignores the value in the model on postback and instead binds the posted value (see here http://weblog.west-wind.com/posts/2012/Apr/20/ASPNET-MVC-Postbacks-and-HtmlHelper-Controls-ignoring-Model-Changes for more details on how this works).
A way around this is in your post action to do
ModelState.Remove("HtmlContent");
and then it will bind the value in your view model instead of the posted value.
So in my case, the issue wasn't actually with tinymce but with the way form posts work in asp.net mvc. Hope this helps someone.
Does a look at the entity_encoding setting help?

ASP.Net Page abstraction

We have a win application that shows a web form in a web browser.
In order to get data from this web form we are using a hidden text box and get its text using HtmlDocument object of web browser control.
I want to make an abstraction of this web form that has this text box element so that other forms can use this abstraction.
I made a web control and put the text box on it.I thought that if I put this control on my page it would have the text box.When i ran my application I noticed that the text box had been rendered but had its control name in its name (WebControl$TextBoxName) and its id(WebControl_TextBoxName) and the win app throw an exception since it couldn't find the element by its id(TextBoxName).
So here's my question:
How can I make an abstract web form/web control that has some elements on it and I can use it to make my final forms have these elements on them? (their names and ids should not be changed)
Thank you for your help
dotNet 4.0 supports static id's so they don't get mangled, read up on Client Id Mode
Alternatively, you could override the render of your control to output a standard html hidden form field with whatever ID you want, and then also add a custom property that will return the textbox that will hide the fact that it isn't an asp.net server control.
Though I've never used the browser control in WinForms, I think what you want to use is a Master Page. Assuming what you're rendering in the browser control is an ASPX page, create a Master Page with the hidden text box that you want to grab your data from, and tell all of the pages you want to have that common control on to use your Master Page. When the page renders, the control id will then be "ctl00_TextBoxName". There is no way of getting around the ID concatenation, since unique IDs are needed and that's the only way to guarantee uniqueness with all the nested control abilities of ASP.NET. However, doing this will guarantee you always have that control named the same on every new form you create that inherits the Master Page. Hope that helps!
In summary (because who reads paragraphs?):
Create Master Page
Place your common control in the Master Page
Have your Form inherit the Master Page
You can read up on how Master Pages work in MSDN's Documentation.

loading value to asp.net control using javascript

iam into problem of reading the value of the control which i alterd using javascript
the sequence goes like this
i got the text box control by using its id
cleared the value of the text box
make the control disabled.
when i tried to retrive the value of the textbox in aspx.cs
iam still getting the old value of the text box which i actualy cleared in the javascript
kindly suggest me to over come this issue
Thanks
Disabled input controls don't get their values posted back so ASP.Net doesn't know you changed the value. You need to enable the control.
With ASP.NET Web Forms, IDs for elements get assigned automatically by the Page on the server side. It is tricky, but possible, to manipulate element values using javascript. One way to avoid this would be to use ASP.NET MVC where the HTML would be rendered as is and javascript or jquery can be easily used to "play" with the HTML elements. We need more information to help you with the details of your request.

Modifying <asp:label> in form

I am developing a form using all asp:textbox and asp:label. Currently, I am using the RequiredFieldValidator to validate text boxes and display an error inline. What I am trying to do is to change the color of one of the asp:labels after validation fails for one of the textboxes fields. Would I accomplish this with javascript, or is there any commands that can do it within asp to modify labels. I would really appreciate any help and code examples.
I'd say that javascript is the way forward here if you don't want to postback to the server. If you use ASP.NET only the page will normally have to be posted back so that the server can change the properties of the label - not very user friendly. A colleague of mine has accomplished this very nicely using JQuery (a javascript libraray) but unfortunatly I don't have a copy of the code to hand. He's an SO user too so I'll pass on a link to this post for you.

Resources