.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

determining if there is content in a ContentPlaceHolder when using Html.RenderPartial

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
 
What I'm trying to do is use one master page with two different layouts.  Currently we have a "master" master page that has all the common elements and two master pages that use it for the two different layouts.  This gives us 3 master pages and there's developer confustion and it is a bit of a hassle to keep them consistent.  What I'd like to do instead is say "if there's anything in the MainContent ContentPlaceHolder, show the single column layout, otherwise show the two column layout".From what I've read you're supposed to be able to do this by using something like the following:<% if (this.MainContent.Controls.Count > 0) //single column layout { %> <div class="center-column-middle clearfix"> <!--.form-holder--> <div class="form-holder"> <asp:ContentPlaceHolder ID="MainContent" runat="server" /> </div> <!--/.form-holder--> </div> <% } %> But this.MainContent.Controls.Count retuns zero when the ContentPlaceHolder uses Html.RenderPartial.  For example, this works fine:<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> blah blah blah </asp:Content> This causes this.MainContent.Controls.Count to return 1.  If I rem


View Complete Post


More Related Resource Links

& in JSP?

  

Hi

I am typically an ASP.NET programmer, and I am familiar with ASP masterpages.

Because, I also know Java, I was handed a JSP project.

I am looking for an equivalent to <asp:Content> whereby I can wrap multiple lines of code/HTML between the open and close tag; for example like so:

<asp:Content ContentPlaceHolderID="content_id" >
<div>
<p>Hello, World</p>
</div>
</asp:Content>


However, the closest thing I found is <jsp:param name="param_title" value="param_value" />, but this is an inconvient solution because the param needs to be inclosed within double quotes, whereby multiple lines of code/HTML will need be a series of concatinated strings.

<%
String param_value =
"<div>"
+ "<p>Hello, World</p>"
+ "</div>"
%>

<jsp:param name="param_title" value="<%= param_value %>" />

Ideas?


HTML.RenderPartial vs HTML.EditorFor

  

This maybe a lame question but I wanted to understand the detailed differences between HTML.RenderPartial and HTML.EditorFor. I am using ASP.NET MVC2 with Framework 4.

Can someone point me to a link?


Html.RenderPartial appears to be stripping Model of custom attributes

  

Hello,

I have implemented a custom ModelMetadataProvider so that I can decorate my view models with some custom attributes and everything was working fine until I made use of a Partial View.

The following code in my view works fine: -

<%: Html.DisplayFor(x => x.Results) %>

Results is a List which renders a custom display template and is also decorated with a custom attribute.  Using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  If I look at the attributes collection parameter I can see that it does contain my custom attribute thus everything working as expected.

However, if I replace the above with the following line of code in my view then it breaks: -

<% Html.RenderPartial("ApplicationSearchResults", Model.Results, new ViewDataDictionary()); %>

All the Partial View contains is: -

<%: Html.DisplayFor(x => x) %>

Again using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  But this time if I look at the attributes collection parameter my custom attribute is not there.

Any idea

Page has one or more controls that do not correspond with con

  
I'm posting this in VS 2008 forum since I wasn't getting this error when this was in VS 2005.  It's complaining about my content tags but I have not a clue why, everything looks fine to me.  I've included the master page so what's the deal? <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Sub.master.cs" Inherits="Web.MasterPages.Sub" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title id="Title" runat="server" /> <link id="main_styles" href="~/main.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { background-image: url(images/back.jpg); } .style1 {color: #B92722} #bigImg { position: absolute; display: none; } </style> </head> <body class="Mainbody"> <form id="form1" runat="server"> <!-- Main Table --> <div class="centered-table"> <table width="100%" border="0" cellspacing="0" cellpadding="0"&g

How do I turn off HTML validation in the Content Editor Web Part?

  
I'm fairly used to SharePoint 2007, where I could inject pretty much whatever I wanted into the CEWP, and among other things affect the page style or create div-based layouts. However, in SharePoint 2010, inserting code into the CEWP seems to go through a HTML validation process, which inserts and converts the original HTML code and ends up in incorrect results. How can I turn off this HTML validation stuff, or alternatively, is there any other way for me to inject HTML into a web part as I wish?

Reading WPF rich text box content in HTML format

  
Hi, I am using WPF RichTextBox. From that, I am reading the content in RTF format using the following code. TextRange textRange = new TextRange(paramRichTextBox.Document.ContentStart, paramRichTextBox.Document.ContentEnd); MemoryStream msData = new MemoryStream(); textRange.Save(msData, DataFormats.Rtf); //get the data from the selected range //strData = textRange.Text; strData = ASCIIEncoding.Default.GetString(msData.ToArray()); I also found that there is an option called DataFormats.HTML. Hence, I tried using this but ended up with error. Is there any other way to read the content of RichTextBox in HTML format? Thanks in Advance!!! Best Regards, Subalakshmi Vijayarajan.

HTML Content into Text

  

Hey all,

 

is it possible to convert html into text in a field?

I've got e-mails in my report where it is html and I would need to print and display it without html.

 

Regards,

Patrick


Dropdownlist posted back html content,firefox alarms "Invalid postback or callback argument"

  

Ok probably you might have seem a dozens of post's titled "Invalid postback or callback argument" but this one is different.

Application that i am creating is simple content editor using the FCK editor.net Control (the content is HTML Encoded before saving t0 DB and then Decoded back again when displaying). just a simple drawing of of its ui is like this

DdlPages < listing the pages Whose regions/controls value can be edited> Databound

DdlRegions <listing the controls whose content can be edited> Databound on DdlPages selected index change

===========Retreived from DropDownlistRegions selected Index Change===========

txtName <a simple name for the region, user friedly identity >

==> FCK Editor <==

<Save Button> <Discard Button>

=================End===========================

I am not such a good designer but hope you understand the UI layout.

This thing works flawless on IE 6,7,8

Process:

DropdownlistRegions holds the content to be displayed in the txtName and FckEditor. This is done by forming a custom concatenated column containing the txtName and Fckeditor(HTML content) separated by a ' ^ ' character. and then databound the column to the Dropdownlist value property.

So on selected index chang

How to use AJAX editor with HTML content?

  

I have a AJAX editor and I want to put the HTML content in a database and I want to get the HTML data from the database to put in the HTML editor, in HTML mode.

So I do:

Editor1.ActiveMode = AjaxControlToolkit.HTMLEditor.ActiveModeType.Html;
        Editor1.Content = MessageLabel2;

Editor1.ActiveMode = AjaxControlToolkit.HTMLEditor.ActiveModeType.Html;

Editor1.Content = data_from_database;


But what happens is that I get the HTML data from the database in designmode in the editor, so I have HTML in designmode and HTML to HTML in HTMLmode (and that is not what I want of course).

Of course I want only HTML in HTML mode and in designmode I want the normal text.

How can you do this and is this possible?



Html.Partial and Html.RenderPartial

  

Hi,
Whats the difference between Html.Partial and Html.RenderPartial?

        <%= Html.Partial("PriceDetail", Model) %>
        <% Html.RenderPartial("PriceDetail", Model); %>


 Output is same.

 

Thanks


WCF returning "The content type text/html of the response message does not match the content type of

  
I have a WCF service I am trying to run on a new installation of 64-bit Windows Server 2008 IIS. Although it runs fine on Windows 2003 IIS, it is throwing the error in the thread title, which appears to be a server config issue, but I am not sure. Googling and searching the MSDN forums did not turn up a solution. I tried running WCF Logging, but that didn't help either.

Does anyone have any suggestions on how to solve this probelm?

-------------------------------------------------------------------------------------
Here is the error:

The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content=&qu

What is the best way to upload html content?

  

I am looking for a solution that can help my SharePoint contributors to be able to more easily create linked pages in SharePoint 2007.  They need to be able to upload about 7 files at a time, the first one being the TOC (table of contents) and the rest being the links from the TOC.  Thing is really cumbersome to do using the native web interface because they cannot "browse to" the subsequent pages when inserting a hyperlink.  In essence, they need to know the URL and this is really hard for them.

I would love to have something simple like FrontPage.  Something that allows them to simply create an HTML page and link to the rest by dragging the other pages into the body of the page you want the link to be in.  We have researched SharePoint Designer, but that does not seem to cut it.  SharePoint Designer seems to be more of an admin/management too

html table content at top

  

i have to column

and onr row

column second text alway align in center

i want that second cell align data at top of the cell.


How to show HTML Content in Winform

  

Hi,

Am trying to create an RSS feed reader. And when i read the data from RSS, i get HTML content. Am clueless as how can i show the content. In fact, there is web browser to show the content, but not interested in the WebBrowser. Is there any other control like RichTextBox which can hold the HTML data and show the text as is from Web.

Am trying to use all the Unicode data content and UTF format. This may not be for the WPF forum, but i couldn't find the Windows forum, hence is here.

Thanks for reading


Every thing is perfect as long as you share

remove html tags from that text being extracted from html content

  

Hi there

I have been trying to extract text from the html content ,But, had resulted with some html tags within the extracted text  , what i should i do in order  to extract only plain text wothout having too much tags or stricpts , i am testing  on differents webpages,so html elements are unknow or chagnes from time to time .i am using Html Agility Pack also . here some of code

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

  doc.Load(new StringReader(result));

   HtmlNode bodyNode = doc.DocumentNode.SelectSingleNode("//body");

   string results  = bodyNode.InnerText.ToString();

regex code
         public string removehtmltags_Regex(string source)
        {
            return Regex.Replace(source, "<.*?>", string.Empty);
        }
  
   result from this code ,

 

2:59:46 PM: var _GlobalNavHeaderUtf8Encoding=true;var includeHost="http://include.ebaystatic.com/";Skip to main contentBuyMy eBaySellCommunityContact usHelpBasketBasketvjo.darw

How to show HTML Content in Winform

  

Hi,

Am trying to create an RSS feed reader. And when i read the data from RSS, i get HTML content. Am clueless as how can i show the content. In fact, there is web browser to show the content, but not interested in the WebBrowser. Is there any other control like RichTextBox which can hold the HTML data and show the text as is from Web.

Am trying to use all the Unicode data content and UTF format. This may not be for the WPF forum, but i couldn't find the Windows forum, hence is here.

Thanks for reading


Every thing is perfect as long as you share

How to change the content of an html file using an aspx file?

  

Hi everyone,

I would really like to have a little help, it should be easy but i can't find the answer

and it's been a while since iv'e done something with asp.net..

what i have now is a regular html pages website.

in some of the pages i have galleries,

I would like to make an aspx page to manage the content of the galleries or any other set-in advance content.

It's kind of a CMS, but it's not, since i would not be using a database.

what i want is just to get the admin's content from the aspx page

and send it to overwrite the images or the content of the DIVS in the html page.

at the final outcome, i will only want to have html files and one aspx file for the admin's editing use.

what is the most simple way to do that without using CMS? 

Thanks a bunch!

Roy.


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend