0

I have "export" button, onclick event creates markup of some current asp.net page's controls (via RenderControl), then I want to wrap this markup into valid html body and give a user as an ordinal html file.

The question is how to accurately and easily gather all css, referenced on current page (it may include axd-resources, link tags and inline styles) and attach this inline to my markup?

Alexander
  • 1,152
  • 1
  • 16
  • 18

2 Answers2

0

You can add cssClass property in your code behind

     //SlideShowDiv is the id of th div in which you add your sever control
    SlideShowDiv.Controls.Add(new System.Web.UI.WebControls.Image()
        {   CssClass ="YourCssClass",
            ImageUrl = slideShowImages[i].ImageUrl,
            ToolTip = slideShowImages[i].ToolTip,
            Width = slideShowImages[i].Width,
            Height = slideShowImages[i].height,
            ImageAlign = ImageAlign.AbsMiddle
        });
gwt
  • 2,331
  • 4
  • 37
  • 59
  • This is all good, but what i need is to, having something like a piece of markup (tables, divs, spans) to add valid html header to it and in it - style tag, containing all required css styles, used in current page – Alexander Aug 08 '12 at 11:33
  • Ok, I can see the only way is to use CSS parser - to feed one css file after another to it. Then to use resulted name-value collection of css properties and to construct inline css style from it for my new page. Cannot figure out, how to read those css that are in axd (webresources)... – Alexander Aug 08 '12 at 15:54
  • Well, now my problem is: how to get current page markup in server-side? I am trying to do this via Page.RenderControl, but suffer problems with modalPopupExtenders, present on this page. – Alexander Aug 09 '12 at 13:05
  • You should set the runat property of the markup to server ! I mean the markup in wich you are creating other markups ! in the above code
    . by the way if my post was your answer please mar It as answer so then other people who have the same question will have access their answer
    – gwt Aug 09 '12 at 16:38
  • I know it. I've overridden Page Render method and now successfully captured markup - saved it into page variable an read it in the control's unload method. But current problem is that GetManifestResourceStream method does not return data for my telerik css, that are build in webresources, it returns null :( – Alexander Aug 10 '12 at 12:14
0

What required is to override Render handler for the Page and save its markup into property. Then in UnLoad handler of control to use this property for extracting CSS from it and construct result page markup using RenderControl method without any problem ;)

Alexander
  • 1,152
  • 1
  • 16
  • 18