Rectangle 27 28

There are specific issues with using tables in particular ways for layout that can cause problems. One of these is building an entire site layout in a single table in order to handle margins and placement -- because of the way tables are rendered this frequently means a website will not render progressively by the browser engine as the content downloads, and can only be rendered after the entire thing has been received. For a large page or slow modem user, they may be staring at a blank page for quite a while, which is a "Bad Thing". Never mind a lot of the inconsistencies in table rendering in the mozilla/ie5 generation of browsers that made consistent cross-browser table layouts somewhat painful, especially with images in the cells.

Supporters of the pure div path like to talk about content vs. presentation, because in theory HTML 4.01 is pure content, all of it meaningful. The divs provide meaningful organizational structure in an abstract sense, which is then given presentation exclusively by CSS. In these arguments, tables are valid only if being used to contain actual tabular data. Of course, this ignores the fact that for any sufficiently complex layout, there are almost always quite a few empty divs floating around simply to support the necessary hooks for presentation CSS, breaking the first level of this abstraction. Once this abstraction is broken, there's no law stating that, when your layout simply requires a presentation hook in the HTML that has no meaningful content, a div is somehow more appropriate than a table. If you are stuck with the choice of a meaningless div or a meaningless table in order to make your layout work, choose whichever is easier.

In the end, it's about being aware of the limitations in all methods and using the one that is most appropriate. There are many cases where using a table is simply easier than setting up a pointless (i.e. not-content-meaningful) array of divs, and the table rendering limitations don't apply. If the table is small and represents a minor chunk of the interior content, the rendering delay is not relevant.

I stopped using tables for structural layout about 2 years ago, and I have NEVER added an empty element to help with structure. It is perfectly fine to add divs and spans for help with structure, but they should still contain content.

correction, since I stopped using tables for structural layout, I have NEVER added and empty element...

I really agree with you're pragmatic approach to this problem. To really take advantage of CSS does require using div's and spans in the ways you describe... Take a look at CSS Zen Garden for a wicked example of leaving CSS hooks in HTML....

You may not have added an empty element, but you have added plenty of browser specific hacks or javascript correction code --both of which are awful. Or you create only simple pages.

That would be partly correct. I have gone through the learning process by adding hacks, but once you get used to it, the cleaner you make your HTML/css the easier it is to get it to look and behave the way you need it. My premise is that if it's not working, you probably need to remove something rather than add something.

html - Why use tables to structure your layout? - Stack Overflow

html css html-table
Rectangle 27 28

There are specific issues with using tables in particular ways for layout that can cause problems. One of these is building an entire site layout in a single table in order to handle margins and placement -- because of the way tables are rendered this frequently means a website will not render progressively by the browser engine as the content downloads, and can only be rendered after the entire thing has been received. For a large page or slow modem user, they may be staring at a blank page for quite a while, which is a "Bad Thing". Never mind a lot of the inconsistencies in table rendering in the mozilla/ie5 generation of browsers that made consistent cross-browser table layouts somewhat painful, especially with images in the cells.

Supporters of the pure div path like to talk about content vs. presentation, because in theory HTML 4.01 is pure content, all of it meaningful. The divs provide meaningful organizational structure in an abstract sense, which is then given presentation exclusively by CSS. In these arguments, tables are valid only if being used to contain actual tabular data. Of course, this ignores the fact that for any sufficiently complex layout, there are almost always quite a few empty divs floating around simply to support the necessary hooks for presentation CSS, breaking the first level of this abstraction. Once this abstraction is broken, there's no law stating that, when your layout simply requires a presentation hook in the HTML that has no meaningful content, a div is somehow more appropriate than a table. If you are stuck with the choice of a meaningless div or a meaningless table in order to make your layout work, choose whichever is easier.

In the end, it's about being aware of the limitations in all methods and using the one that is most appropriate. There are many cases where using a table is simply easier than setting up a pointless (i.e. not-content-meaningful) array of divs, and the table rendering limitations don't apply. If the table is small and represents a minor chunk of the interior content, the rendering delay is not relevant.

I stopped using tables for structural layout about 2 years ago, and I have NEVER added an empty element to help with structure. It is perfectly fine to add divs and spans for help with structure, but they should still contain content.

correction, since I stopped using tables for structural layout, I have NEVER added and empty element...

I really agree with you're pragmatic approach to this problem. To really take advantage of CSS does require using div's and spans in the ways you describe... Take a look at CSS Zen Garden for a wicked example of leaving CSS hooks in HTML....

You may not have added an empty element, but you have added plenty of browser specific hacks or javascript correction code --both of which are awful. Or you create only simple pages.

That would be partly correct. I have gone through the learning process by adding hacks, but once you get used to it, the cleaner you make your HTML/css the easier it is to get it to look and behave the way you need it. My premise is that if it's not working, you probably need to remove something rather than add something.

html - Why use tables to structure your layout? - Stack Overflow

html css html-table
Rectangle 27 2

Without much information I suspect the error happens after you submit. It happens because you are using the same view in your POST action as in your GET action, but not passing any data. You get the error since the view is trying to render the HTML expecting the model to be a valid object.

Try using a different view in your POST action, like this:

return View("Added");

Create a view with that name which does not have a model and that part should work.

NOTE: Best practice would be to create a view-model that contains all data you need (IngredientsList, AmountsList), so you don't have to use ViewBag for anything. Something like:

public class IngredientViewModel
{
    public Ingredient Ingredient { get; set; }
    public IEnumerable<Ingredient> IngredientsList { get; set; }
    public IEnumerable<Amount> AmountsList { get; set; }
}

Use this class as your model. Btw, (I'm assuming it's a typo in your question) make sure you are using consistent pluralization for your class names. Either Ingredient or Ingredients.

c# - ASP.NET MVC ViewData Error - Stack Overflow

c# asp.net-mvc
Rectangle 27 1

Using Scott Gu's blog as a reference, I also came across the same problem loading server controls in my widgets (e.g. GridView and RadTreeView controls would cause the same error) for our company's dashboard. Following John Saunders's tip, I added an HTML form control and script manager control (for RadTreeView controls) and it fixed the problem. Now my user controls render out as pure HTML. w00t!

[WebMethod]
public static string[] LoadWidget(string widgetID, string widgetPath)
{
    try
    {
        var pageHolder = new Page();
        var form = new HtmlForm();
        var viewControl = (UserControl)pageHolder.LoadControl(widgetPath);
        var scriptManager = new ScriptManager();
        form.Controls.Add(scriptManager);
        form.Controls.Add(viewControl);
        pageHolder.Controls.Add(form);

        var output = new StringWriter();
        HttpContext.Current.Server.Execute(pageHolder, output, false);

        return new string[]
        {
            widgetID, output.ToString()
        };
    }
    catch (Exception e)
    {
        // handle error...
    }
}

user controls - Asp.net error creating usercontrol from WebMethod - St...

asp.net user-controls
Rectangle 27 1

Maybe now your browser is trying to render the html output and it just result in a "blank page". Did you try the "view source" option? share|improve this answer answered Jan 19 '11 at 15:25 Francesco Laurita 19k54659

Yes, you are correct, I do see the echo part in "view source". So I need to get the browser to show it.

strip_tags

PHP echo $array[$i] not showing anything - Stack Overflow

php arrays echo
Rectangle 27 1

Using the C# "dynamic" keyword in HTML helper methods seems to be the root of the problem. The main render method gets a RVA value of 0 which is causing the "Method has no implementation (No RVA) exception." error when asp.net tries to resolve the type containing the method.

asp.net mvc 4 - .Net 4.5 bug with MVC4 - Stack Overflow

asp.net-mvc-4 .net-4.5 asp.net-4.5
Rectangle 27 0

I would suggest that the easiest thing to do would be to have separate validation and post actions triggered by the submit button. You'd first do an AJAX validation/post that returns JSON status and potentially an array of validation errors (strings). Actually an empty list would probably suffice as evidence of success so you could possibly omit the status. Once you've done your server side validation, then invoke another action via AJAX that would retrieve the data to display. This action would render a partial view and return HTML.

That's an interesting idea. However, I'd like to leverage the Html.Validation extension methods in the View which display the validation errors in the ViewData's ModelState.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

Returning both status and HTML from Ajax Post in ASP.NET MVC - Stack O...

asp.net-mvc
Rectangle 27 0

I had a similar issue this morning with AbcPdf9. I added code to test the engine types and GECKO worked, then I swapped it back to MSHTML, and it still worked. So it was a temporary issue.

using (var document = new Doc())
{
    document.HtmlOptions.Engine = EngineType.Gecko;
    ...
    ...
}

This code calls the method that converts the html to PDF, but calls it twice if necessary, since it will only fail once:

try
{
    return GeneratePdfFromHtml(html, width, EngineType.MSHtml);
}
catch (Exception ex)
{
    /* detect this known issue, swapping the rendering engine once seems to fix it */
    if (ex.Message.ToUpper().Contains("BLANK"))
    {
        return GeneratePdfFromHtml(html, width, EngineType.Gecko);
    }
    throw;                            
}

Then you can add a parameter to the method that does the conversion:

public byte[] GeneratePdfFromHtml(string html, int width, EngineType engineType)
    {
        if (string.IsNullOrWhiteSpace(html)) throw new ArgumentNullException("html");
        if (width < 100) throw new ArgumentOutOfRangeException("width");

        try
        {
            using (var document = new Doc())
            {
                document.HtmlOptions.Engine = engineType;
                ...
                ...

If you have a suggestion or different solution, please leave a comment.

abcpdf - ABCPDF6 issue: "HTML render is blank" but web page output is ...

abcpdf
Rectangle 27 0

You have a few options, but you can't use a repeater to do it.

ASP.NET won't output the HTML defined in an ASPX until it hits the rendering stage of the page lifecycle. Before that, almost anything could happen to the Page (in Page_Init, Page_Load, etc.): it might add or remove controls to the page, it may bind data sources, etc.. So there's no way to know what to send to the client yet.

One option is to build the report from the client using AJAX: load the HTML first, then modify it with incremental calls to the server until you've consumed all of the report data. That would let you break your reports up into whatever size chunks you want, but it could get rather complicated. (On the other hand, maybe someone has already built a control to facilitate this.)

Another option is to take control of your HTML generation and write the entire page manually in your code-behind class (instead of using a nice, easy-to-read .aspx template). To see this in action, create a completely empty .aspx (apart from the @Page declaration), and put this in its Page_Load method:

protected void Page_Load(object sender, EventArgs e) 
{
    Response.Write("<html><body><ul>");

    // this could be iterating a data reader
    for(int i=0; i<5; i++) 
    {
        Response.Write("<li>Item " + i.ToString() + "</li>");

        // you might tweak your buffer settings instead of flushing on
        // each write - this is just for demonstration purposes
        Response.Flush();

        // this just dramatizes the fact that it's streaming
        // by adding a two-second delay
        System.Threading.Thread.Sleep(2000);
    }
    Response.Write("</ul></body></html>");
}

I was thinking on these lines. It works this way in php and other web stacks anyway. Thanks for your time.

Render asp.net repeater as-and-when chunks of html is ready (streaming...

asp.net streaming asynchronous
Rectangle 27 0

Using Scott Gu's blog as a reference, I also came across the same problem loading server controls in my widgets (e.g. GridView and RadTreeView controls would cause the same error) for our company's dashboard. Following John Saunders's tip, I added an HTML form control and script manager control (for RadTreeView controls) and it fixed the problem. Now my user controls render out as pure HTML. w00t!

[WebMethod]
public static string[] LoadWidget(string widgetID, string widgetPath)
{
    try
    {
        var pageHolder = new Page();
        var form = new HtmlForm();
        var viewControl = (UserControl)pageHolder.LoadControl(widgetPath);
        var scriptManager = new ScriptManager();
        form.Controls.Add(scriptManager);
        form.Controls.Add(viewControl);
        pageHolder.Controls.Add(form);

        var output = new StringWriter();
        HttpContext.Current.Server.Execute(pageHolder, output, false);

        return new string[]
        {
            widgetID, output.ToString()
        };
    }
    catch (Exception e)
    {
        // handle error...
    }
}

user controls - Asp.net error creating usercontrol from WebMethod - St...

asp.net user-controls
Rectangle 27 0

I don't know anything about SignalR but i'm pretty sure the problem has something to do with your view trying to render HTML for properties of a null object.

I had a skim through the article and cannot see any reference to the actual database that stores the data and no code was provided to generate the database from your code (and the post's author is not clear on wether you will be connecting to an existing database or generating one).

If you don't already have an existing database then you need to tell your Entity Framework code to generate one; This article will show you how to do that (the stuff you need is towards the bottom of the post).

Now, looking at the way you have set up your entity class and assuming you haven't already done any of the things mentioned in the two articles, Entity Framework should be creating a database for you automatically (which is the default behaviour - not sure what happens if you don't have SQL Server Express or greater installed though). Have you checked to see if you have a database in your SQL server instance? It should be called BlogPostContext. Fill this with some data and things should now work.

So why are you getting this problem? At the moment you either have

  • A database with no data.

This means your controllers are either

  • Requesting data from something that doesn't exist, OR
  • Requesting data from an empty database

The result you will get back from both scenarios is a null object. This null object is then passed to your views which are then trying to iterate over the null object and generating your exception.

You can verify this in two ways.

  • Check for a null object in your views and only output HTML based on your model if the null check returns false.

For solution 1 something like the following in your view:

@if (Model == null)
{
    <span>No data!</span>
}
@else
{
    // All the auto generated view code goes here...
}

For solution two you need to replace the data retrieval code in your controller. So remove any code like this;

BlogPost blogPost = db.BlogPosts.Find(id)

and replace it with something like this;

BlogPost blog = new BlogPost()
{
    Title = "Use Entity Framework Code-First";
    Post = "blog post body goes here..."
};

IEnumerable<BlogPost> posts = new List<BlogPost>();
posts.Add(blog);

Note: These two solutions are for demonstrating the problem to you and you should revert to using the data retrieval code once you have correctly setup your database.

ASP.NET MVC 3 add controller throws error "Object reference not set to...

asp.net asp.net-mvc-3 ef-code-first nuget signalr
Rectangle 27 0

Can you also include HTML source after it gets render to browser? What if cd.FindControl("ind" + cnt1) returns null in first case?

cd.FindControl("ind" + cnt1).FindControl("txt" + cnt1) as TextBox

First case it will not return null..only from 2nd time it will return as object reference not set to an instance of the object... By the way u have posted the same code what I have tried... Will you elaborate pls...

@Amit... I have added the HTML Source after rendering.. Can you get some idea now... :(

c# - Error in finding dynamic created control - Stack Overflow

c# asp.net html5 file-upload dynamic-controls
Rectangle 27 0

You need to set the Metadata properly - content-type as text/html for your html pages. Once this is through the browser would start to render the pages in the browser rather than downloading them.

amazon web services - Website hosted on S3 just downloads a blank file...

amazon-web-services amazon-s3
Rectangle 27 0

I think the 2 method is the way to go, but just like you said, if you return text/html there is no parameter to tell what is the current state of the request (ok/error), but there is one approach that require you to do a little hack on the ViewEngine and it will let you render partial Views to String format, that way you can return a JSON structure with the state along with a piece of HTML(the partial view).

return Json(new { 
      result = "success", 
      timestamp = DateTime.UtcNow, 
      html = this.RenderToString("View", Model) 
    });

You can take a look at it here.

Ah that makes perfect sense. I should have thought of that as well. Thanks :)

Where to form html when using asp.net mvc and jquery? - Stack Overflow

jquery asp.net-mvc ajax
Rectangle 27 0

If this is happening after rendering a view in response to a POST request, you should be aware that the HTML helpers use the old values because they think there is a validation error. You can find a detailed explanation in this blog post.

This happens not only in POST request, but in GET requests to. An example:

Sorry has left the office at that time. And now decided to write it all in separate answer.

razor - ASP.NET MVC 5 Html.HiddenFor renders incorrect property value ...

asp.net-mvc razor asp.net-mvc-5
Rectangle 27 0

You can also use the Html.Raw and HttpUtility.HtmlDecode helper methods in a view to render validation messages that contain HTML markup. Here's a simple example:

[Required(ErrorMessage = "This message contains <b>HTML markup</b> code.")]
public string MyProperty{ get; set; }
@Html.Raw(HttpUtility.HtmlDecode(Html.ValidationMessageFor(x => x.MyProperty).ToHtmlString()))

ASP.NET MVC - Add XHTML into validation error messages - Stack Overflo...

asp.net asp.net-mvc validation
Rectangle 27 0

This is supposed to be a bug in IE10, So you can render the page in IE9 standards. You need to add following tags inside head tags on html code:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" >

javascript - ajax calendar control Error - Stack Overflow

javascript asp.net ajaxcontroltoolkit
Rectangle 27 0

Alternatively you could write your own ActionResult that writes the contents of the file to Response.Output (could potentially avoid loading the entire file into memory at once albeit it might not be a big issue).

What is the best practice for using ASP.NET MVC to render lots of html...

asp.net asp.net-mvc
Rectangle 27 0

If you explicitly put in a blank string for this in your locale file, then Devise "won't bother" to render the message at all (e.g. there won't even be an empty HTML div).

#en.yml
devise:
    sessions:
        signed_in: 'Signed in successfully.'
        signed_out: ''

I know this is a bit old, but for those of you who are wondering, the locale file is typically located at config/locales/devise.en.yml

ruby on rails - Remove Devise Flash Notices for Sign out - Stack Overf...

ruby-on-rails ruby-on-rails-3 devise authentication