I have an ASCX user control that I want to render to a string instead of direct to the browser. I've tried something like: MyControls.footer ftGen = new MyControls.footer(); System.Text.StringBuilder sb = new StringBuilder(); System.IO.StringWriter twriter = new System.IO.StringWriter(sb); HtmlTextWriter writer = new HtmlTextWriter(twriter); ftGen.RenderControl(writer); return sb.ToString(); but am not having any luck. Anybody have ideas? :confused:
ChrisWFL
Posts
-
Render a user control to a string? -
Need Power-of-Attorney form ASAPI'd be careful. You'll need what's called a "specific power of attorney" and when real estate is involved, it can get tricky. Each state can have different requirements. It might be best if you contact your closing agent (title company?) to get the required form filled in with whatever your state may require. Title companies have attorneys.
-
Basic Auth for ASP.NETYes you can, but to use Basic Auth, it's much easier and better to just turn off anonymous users on that file or directory. IIS will then do it automatically.
-
Returning a collection from a web service functionLeppie's right. An array of A (it's the base class after all) then just cast it back to the appropriate B or C. You can also write a serializer if you want to (they actually aren't that hard in most cases).
-
Basic Auth for ASP.NETCheck out Forms based authentication. .Net will handle it for you. The "login" form can verify the username and password any way you care to handle it.
-
I confused why I can't refresh my pagesYou obviously input something on the default page to cause it to transfer to another, even if it was only click a button. That is the information it wants to send again. You are actually transmitting that information back to the default page (look at your URL, it doesn't change when you transfer). If you do a Redirect instead, it would work (no information going along with it). But that causes a round trip to the server.
-
How can I pass value from codebehind to javascript?Inject the value into the javascript before you send it, or inject a hidden form field with the value and read it from the javascript. Do that with Page.RegisterHiddenField(HiddenFieldName, HiddenFieldValue); Access it with document.formname.HiddenFieldName
-
ASP to convert IIS logsAre you wanting to "pretty print" them? If so, the script would depend on the log format you chose and what fields you chose to log. You'll need to use the Scripting.FileSystemObject if you are truly in ASP. If you're using ASP.Net there are other methods. If not, they are just text files, so you can just link directly to them and they will display in the browser, no assembly required.
-
How can I put controls inside a table cellThis is exactly what I do too. The IDE doesn't let you drop controls into a server side table, so I just drag it onto the page, set whatever properties I want, then switch to HTML view and move it into the table code where I want it to live. It's a pain, but it works.
-
Inserting Records into a Databinded DropdownAfter doing the DataBind() call, do a ddl.Items.Insert(position, new ListItem("value", "display text"));
-
ACTION attributeWe had this problem too. If you view the source of the page, you'll see that .Net has overwritten your action to postback. You might want to put this form on your .aspx page and take out the runat="server" attributes. Don't mess with the form that .Net puts there, just leave it.
-
DropDownList and XML fileThanks, that worked. I was trying not to need a DataSet, but I ended up needing one for another reason anyway. Also, I was trying to use the XML services and get a table back instead of the (proper) other way around of creating a table by reading the XML.
-
please help, session problem.Make sure your ASP.Net State Service is running. By default it isn't. Check in the Services control panel.
-
DropDownList and XML fileHas anyone figured out how to attach an XML file as a datasource for a DropDownList control? For instance, a list of 50 states and state codes to populate a state dropdownlist in a shopping cart.
-
ASP.NET woes ...I'd do this with an Application variable. In the global.asax page, you can set the variable. In the Page_Load function you can then override the setting that's done in the Initialize_Component. You can also use the Advanced setting of the Configuration Properties to store this.
-
LADY BUG FARTSYou can do something like time.Text = DateTime.Now.ToString("h:mm"); I don't remember the exact formatting strings, but the F1 help system gets you there. :rolleyes:
-
Using MapPath in a C# class projectI have a class that is called by an ASP.Net project. The class needs to use MapPath to return the physical location of various files. However, when called from the class, everything is returned relative to the absolute root of the web, not it's actual physical location. This seems to work ok when called directly from the ASP.Net project, just not the class (which is only referenced by ASP.Net). Has anyone figured out how to do this? Especially when using virtual directories...
-
.asmx files dont load in IEYes, that is the problem. Reinstall the framework.