开发者

How to add html saved to a blob directly to page .aspx source

I have a page that I need to allow a user to edit, then I parse the information into HTML and save it to a MS SQL 2008 R2 database. I need to then add this information to an announcements page from the items contained in the database.

I am using C#, so t开发者_如何学Che question is how would I do this? I have a div specifically for the content. Also, is this the best way to allow a user to manage content if I cannot use a cms ( this question is not so vital as I know it is prob more complicated than I realize)?


You can use an asp:Literal control to insert the HTML on the page via the "Text" property on the server-side:

Markup:

<asp:Literal ID="litAnnouncement" runat="server" />

Code-behind:

string htmlAnnouncement = GetHtmlFromDB(); // Get the HTML however you need to as a string.
litAnnouncement.Text = htmlAnnouncement;

I would put the code above somewhere in one of the Load or Init events, either for the page or the Literal control. Of course, there are other ways to do this, but I think this is the most straight-forward given your description.


I didn't get your question completely. but if you want to save data from an HTML element into the SQL data base, then you can add a Sqldatasource control to your page, and then define it with a parameter in the source code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜