 server-side form tag"

I need to generate a pdf with html page contents. I have the following code in Pre_render event:
StringWriter sw = new StringWriter(); 
HtmlTextWriter hw = new HtmlTextWriter(sw);

this.Page.RenderControl(hw); 
string pageContent = sw.ToString();

// Generate PDF file to export
some code..

This throws a "A page can have one server-side form tag". If I override the Render method to do nothing, the generated pdf has no contents. Any workaround to prevent this?

A:

When you get the HTML of the entire page and render it to the client, you now have two forms with the runat="server" attribute. Do not render the entire page to HTML and write it to the client like that. If you update your question and say what you're trying to accomplish (which you should have provided in the first place) then we can give you alternatives to re-rendering the HTML of the entire page to the client.
If you want to generate a PDF with the information that's contained on the page, I suggest you custom build your PDF rather than rendering the page contents to the PDF as the results are less controllable.
However, if you must do the page contents, then put all your page content inside in a Panel, then render than Panel instead of the Page.
<asp:Panel runat="server" id="PageContents">
<%-- Put your page contents here, inside the Panel --%>
</asp:Panel>

Then in your code...
StringWriter sw = new StringWriter(); 
HtmlTextWriter hw = new HtmlTextWriter(sw);
PageContents.RenderControl(hw); 
string pageContent = sw.ToString();

// Generate PDF file to export
some code..

 Q:

DisplayModeProvider issues

Using DisplayModeProvider to choose between views for "Desktop", "Tablet" and "Phone" in a MVC5 web application.  It is my understanding that this class selects the correct provider in order and uses the first provider that returns True.  However, when I step through the code, I find there is a repeated cycle through the code (it goes through multiple times, sometimes over 10 cycles) before deciding on the proper mode. I'm using WURFL Cloud for device detection.  Lastly,
server - side form tag " 

 I necessitate to render a pdf with html page contents. I have the postdate code in Pre_render event: 
 StringWriter sw = new StringWriter (); 
 HtmlTextWriter hw = modern HtmlTextWriter(sw); 

 this. Page. RenderControl(hw); 
 drawstring pageContent = sw. ToString (); 

 // Generate PDF file to export 
 some code.. 

 This throws a " A page can have one server - side shape tag ". If I override the Render method acting to do nothing, the generated pdf has no contents. Any workaround to prevent this? 

 A: 

 When you get the HTML of the integral page and render it to the client, you now own two forms with the runat="server " attribute. Do not give the entire page to hypertext markup language and write it to the node like that. If you update your question and say what you're trying to carry through (which you should have provided in the first place) then we can give you alternatives to re - rendering the HTML of the entire page to the client. 
 If you want to generate a PDF with the information that's contained on the page, I suggest you custom build your PDF rather than picture the page contents to the PDF as the results are less controllable. 
 However, if you must dress the page content, then put all your page content inside in a Panel, then try than Panel instead of the Page. 
 < asp: Panel runat="server " id="PageContents " > 
 <% -- Put your page contents here, inside the Panel --% > 
 < /asp: dialog box > 

 Then in your code... 
 StringWriter sw = new StringWriter (); 
 HtmlTextWriter hw = new HtmlTextWriter(sw); 
 PageContents. RenderControl(hw); 
 string pageContent = sw. ToString (); 

 // Generate PDF file to export 
 some code.. 

  Q: 

 DisplayModeProvider issues 

 Using DisplayModeProvider to choose between views for " background ", " Tablet " and " Phone " in a MVC5 web application.   It is my understanding that this class selects the correct supplier in ordering and uses the first provider that returns True.   However, when I step through the code, I find there be a repeated cycle through the code (it goes through multiple times, sometimes over 10 hertz) before deciding on the proper modality. I'm using WURFL Cloud for device detection.   last,
 segver-side form tag"

I need uo generate a pdf with hvml pags contengs. I have the following code ib Pre_eender event:
StringWritdr sw = nea StringQrittr(); 
HtmlTextWriter hw = new HtmlTswtWricec(sw);

this.Page.RendgrControl(hw); 
vtring pageCondevt = sw.ToString();

// Generate PDF file to evport
soke code..

This thrors a "W pafv gan have one server-side form tag". If I onerride the Rendet method to do nothing, the genfrated pdf has no fontents. Ani wowjaround to pfevent this?

A:

When you ggt the HTML of the entire page avd reuder it to jkw cphent, you nox have two forms wlnh the sunat="setver" attribute. Do nor render the entire pege to HTML and writg it to tha elient like that. If yiu updaje yogr qjwstkon aid aay whwt bou're tryinf to accompoish (which you shoukd yave provided in thq sirst place) then we can give you alterndtibes to re-rendering the YTML of the entire pahe to the client.
If you want to generate a PDF with the infmrmatmov tkqt's cubtwined on the page, I suggest you custom build rkut IDF rather than rcndering the page vojtrgts to the PDW as tks desults are less clntrollwble.
Hiwever, if you must do the page contents, rhen put all tour page content nnside in a 'anel, jhen rrnder than Panel insteab of tge Page.
<asp:Pwnel runaf="rerver" id="PageCongenns">
<%-- Pgt your kxge contents here, inside tie Pauel --%>
</asp:Pxnel>

Jhen in your code...
DtrinnFriter sw = new StrlngWrnter(); 
VtmlTextWrlter hw = new HtmlTextWriter(sw);
PajxContents.RendgrCmntgol(hw); 
strnng paneContent = sw.ToFtring();

// Generatg PDF filz to ebport
some bode..

 Q:

Dis'layModeProvyder issues

Ushjg DisplayMoveProvidew to choise betdden views for "Cesktop", "Tcylet" and "Phone" in a MVC5 web apkljcation.  It is ny obderstanding tnat thys ckafv selects tha cofrezy proxider in orbef anc uses the first proeided that returns Trur.  However, when I ftep through yhe code, I find thtre is a cepeatrd sycle through the code (it goes through lulbiple times, sjmetlmes over 10 cyckes) before deciding on the proper mode. M'm using WURFL Cloud foe device detection.  Kastly,
server-side form tag" I need to generate with page contents. have the following sw new StringWriter(); HtmlTextWriter = new HtmlTextWriter(sw); string pageContent = sw.ToString(); // Generate file to export some code.. This throws a "A page can have one form tag". If I override the Render method to do nothing, the generated has contents. workaround prevent this? A: When you get the HTML of the entire page and render it to client, you now have two forms with the attribute. Do not render entire page to HTML and it the client that. you your question and what you're trying to accomplish (which you should have provided in the first place) then we can you alternatives the HTML the page the client. If to generate a PDF with the on the page, I suggest you custom build PDF rather rendering the page contents to the as the results are less controllable. However, if must do the page contents, then put all your page content inside in a Panel, than Panel instead of Page. <asp:Panel runat="server" <%-- your contents inside the --%> </asp:Panel> Then in your code... StringWriter sw = new StringWriter(); hw = new HtmlTextWriter(sw); PageContents.RenderControl(hw); string pageContent = sw.ToString(); // file export some code.. DisplayModeProvider issues Using DisplayModeProvider choose views for "Desktop", "Tablet" in MVC5 is understanding this class selects the provider in order and uses first provider that returns through the code, I find there is a cycle through the code (it goes through times, sometimes over 10 cycles) before deciding on the proper mode. I'm WURFL Cloud detection. Lastly,
 server-side form tag"

I need to gEnerate a pdF with HtmL paGe ContEnts. i have the followINg coDe in Pre_render event:
StriNgWriTeR Sw = neW stRingWRiter(); 
HtMLTEXTWrItEr Hw = nEw hTmLTextwriTer(sw);

thIs.Page.RendErCOnTrol(hw); 
string PAgEContent = sw.toSTring();

// GeneratE PDf file tO eXpoRT
some CodE..

This Throws A "a page cAn have one SeRVer-sidE Form tag". iF i oVerrIde the Render methoD To DO nothing, the genErated PdF HaS NO coNteNts. Any workArOund tO Prevent THiS?

a:

wHen YOu get the HTML oF the entire pAGe aNd rendEr It tO The cliEnt, yoU nOW haVe two forms wIth tHe runat="seRver" atTRibute. DO Not rendEr the eNtiRe pAge tO hTmL And WrITe iT To The CLieNt like thAt. if You upDate YOUR QuesTioN and Say whAt you're trying To aCcomPLisH (whicH you sHoulD hAve prOvided In the FiRst place) then we cAn giVe you alteRnaTiVes To Re-renDEring tHe HtML Of the enTire pagE To tHe CLIEnT.
If you want to generaTe A pdF With the iNformaTIoN tHAt's contaInEd oN the PAGe, I suGgesT YoU custom bUild yoUR PdF Rather tHaN rendeRiNg tHe pAge coNTentS to the pDF as the ResulTS are less controLLable.
However, iF YoU MUsT Do thE paGe contents, tHen pUT all Your PAgE coNTent iNside In A paNEl, then render than PanEl InsteaD of thE Page.
<asp:Panel Runat="serveR" ID="pageContEnts">
<%-- pUt YOur page contentS here, Inside the PANel --%>
</asp:PaNel>

ThEn in your Code...
StrinGwRiter sw = nEw STriNgWRitER(); 
htMlTextWriter hW = NEw HtMltextWriTer(Sw);
PageCOntEntS.ReNdeRCOntrol(hw); 
sTring pagECOnTeNt = Sw.TOStriNG();

// GeneratE PdF fIlE to ExporT
Some coDe..

 Q:

DiSplaYMOdEproVider isSUeS

uSing diSpLayMOdeprOvideR to cHOosE betweeN views for "desKTop", "TAbLeT" and "PhoNe" in a MVC5 web apPlIcation.  It iS mY unDerstaNDIng that tHis class selects the correCT providEr iN ordeR and Uses the fiRst ProvidEr tHAt retuRns TruE.  HoweVeR, whEN i step THRoUgh ThE code, I find THEre Is a rePeAted Cycle thRough the code (it goes THroUgh multiple tiMes, SomeTIMeS ovER 10 cYCleS) bEForE DEciding on the proPer mode. I'm uSiNG WuRFL Cloud fOR deViCe detecTion.  LasTly,
 server-side form tag"

Ineed to ge nerat e a  pd fwith  htm l page content s . Ihave the following cod e inPr e _ren d er  even t:
Stri n gW r i ter  s w= n ew St ringW rit er(); HtmlTextWr ite rhw = new Htm l Te xtWriter(s w); 

this.Page. Ren derCon tr ol( h w); str ing p ageCon t ent =sw.ToStri ng ( );

// Generat e PD F fi le to export
some co d e..

This thro ws a " Ap ag e can  ha ve one ser ve r-sid e  form t a g" . I f I override theRender meth o d t o do n ot hin g , thegener at e d p df has no c onte nts. Anyworkar o und top reventthis?
A: 

W heny ou  g etth e  HT M Loft heentire p ag eand r ende r i t  tothe  cli ent,you now havetwo  for m s w ith t he ru nat= "s erver " attr ibute .Do not render t he e ntire pag e t oHTM Land w r ite it  to  th e clien t liket hat .I f yo u update your ques ti o n  a nd say w hat yo u 'r et rying to  a cco mpli s h  (whi ch y o ushould h ave pr o vi de d in th efirstpl ace ) t hen w e  can  giveyou alte rnati v es to re-rende r ing the HTMLo ft h ee ntir e p age to theclie n t.
I f yo u  w ant to ge nerat ea  P D F with the informat io n that 's co ntained on th e page, Is u g gest you  cus t om build your PDF  rath er than re n dering t he pa ge conte nts to th e PDF as t heres ult s a r e  l ess controlla b l e.
H ow ever, i f y ou must  do  th e p age  c ontents,then put  a ll  y ou r p age c o ntent in si dein  aPanel ,  thenrende r th an  P a nel  instea d  o f thePa ge .
<a sp: Pa nel r unat = "se rver" i d="PageCo nte n ts"> 
< %- - Put y our page cont en ts here, i ns ide  the P a n el --%></asp:Panel>

Then in y o ur code ... 
Stri ngWr iter sw =  ne w Stri ngW r iter() ; 
Htm lText Wr ite r hw =n e wHtm lT extWriter( s w );PageC on tent s.Rende rControl(hw); 
str i ngpageContent =  sw .ToS t r in g() ; 
/ / G en e rat e PDF file to exp ort
some c od e .. 

 Q:

Dis p lay Mo deProvi der iss ues
U sing Di splayMode Providerto  cho o s e b etween vie ws for " Desktop", "Tabl e t"  and"Ph one" i na M VC5 w eb app l ica tion.   It i smy und ersta nd ing that  this class selects the  corre ct pr ovi der in or der and  uses the  fir st provide r t hat  retu rns True.   Ho w ev er, whenI st e p through th e c o d e,  I find the r e isa rep eat e d cycl e th rough the code (i t  goes throughmult i p letim e s, s om etimes over 10  cy cl e s ) before  d eciding onthe prop er mode.  I'm u sing W URFL Cl o u df or dev icedet ection. Las tl y ,
 server-side_form tag"

I_need to generate a_pdf with_html_page contents._I_have the following_code in Pre_render_event:
StringWriter sw = new_StringWriter(); 
HtmlTextWriter hw_=_new HtmlTextWriter(sw);

this.Page.RenderControl(hw); 
string pageContent = sw.ToString();

// Generate PDF file to export
some code..

This throws a_"A_page can_have_one_server-side form tag". If I_override the Render method to_do nothing,_the generated pdf has no contents. Any workaround_to_prevent this?

A:

When you_get the HTML of the entire page and render_it to the client, you now_have two forms_with_the_runat="server" attribute. Do not_render the entire page to HTML_and write it to the client_like that. If you update your question_and say what you're trying to_accomplish (which you should have_provided in_the first place) then we_can give you_alternatives to_re-rendering the HTML_of the entire page to the_client.
If you want_to generate a PDF with the_information_that's contained on_the_page,_I suggest_you custom build_your_PDF rather_than_rendering the page contents to the_PDF_as the results are less controllable.
However, if_you must do the_page_contents, then put all_your page content inside in_a Panel, then render than Panel_instead of_the Page.
<asp:Panel_runat="server" id="PageContents">
<%-- Put your page contents here, inside the Panel --%>
</asp:Panel>

Then_in your code...
StringWriter sw = new_StringWriter(); 
HtmlTextWriter hw =_new HtmlTextWriter(sw);
PageContents.RenderControl(hw);_
string_pageContent = sw.ToString();

//_Generate_PDF file_to export
some code..

 Q:

DisplayModeProvider issues

Using DisplayModeProvider to_choose between_views for "Desktop", "Tablet" and "Phone"_in a MVC5 web_application._ It is my understanding that_this class selects the correct provider_in order and uses the_first_provider_that returns True.  However,_when I step through the code,_I find there_is a repeated cycle through the code_(it_goes through multiple times, sometimes over_10_cycles) before deciding on the proper_mode._I'm_using WURFL Cloud for device_detection.  Lastly,