.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Html + string Builder

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net


Can anyone explain me what is hapening? I have a piece of code like this, and i'm using StringBuilder to create a html page however there's something worng.

sb.Append("<td " + strColorRef + " >" + item.MarDat == null ? "" : ((DateTime)item.MarDat).ToString(formDatMar) + "</td>");

value of  strColorRef  is  style="color: #FF8000;"

                foreach (var item in listaAlert)

value of  item.MarDat == null ? "" : ((DateTime)item.MarDat).ToString(formDatMar) is  11-Out

value of formDatMar is dd-MMM

The final result is  11-Out</td>

What is going on, i can't understand that.  

View Complete Post

More Related Resource Links

Get Public String in HTML doesn´t work in this case?

Hi, I am trying to retreive a public String in code behind in the HTML code like below but the compiler says that there is Illegal characters in path. I wonder if it is possible to pass a public String here in this case like this ?  <%@ Page Language="C#" ValidateRequest="false" AutoEventWireup="true" CodeFile="Hello.aspx.cs" Inherits="Hello" %> <%@ PreviousPageType VirtualPath="<%# previousURL%>" %> (code behind): public String previousURL = "someURL";  

HtmlHelperExtensions in MVC2 return a HTML string, unencoded. In MVC3 this tring is encoded!

 HtmlHelperExtensions in MVC2 return a HTML string, unencoded. In MVC3 this string is encoded! How can I return unencoded HTML to a Razor view in MVC3? 

Html.DropDownList using a List

This has to be a simple thing, but for whatever reason, I'm just not finding it. I want to use the HTML Helper function to create a DropDownList based on a List<string> (and actually have it bind to the data field on the model).  The simplest example, I suppose, would be: <%: Html.DropDownList("Material", new SelectList(new[] {"Wood","Brick","Metal"})) %> This creates the items in the drop-down, but of course, there's nothing in this line that would bind it to my model (model.Material).  I've done drop-downs with collections of models, where you can bind the Data and Display attributes to properties of the class, but I don't have a class here, just a List. Any ideas?

Runtime error in string builder which was declared static


My code to insert data is as follows it works for the first time if i tried to insert data for the second time i am getting the error

My complete code




using System . Collections . Generic ;
using System . Text ;
using System . IO ;
namespace ACHDAL
public class EntryDetail

int [] debits ={ 25 , 26 , 27 , 28 , 29 , 35 , 36 , 37 ,

Runtime error in string builder which was declared static


My code to insert data is as follows it works for the first time if i tried to insert data for the second time i am getting the error

object reference not set to an object


find a string beetwen tag


hi guys

i have a string contain :

kasjbdfkjasbdf klsajdfl

ajbfk  <html> ... </html> ksadfksadfwie...

now i wnat to find string beetwen <html> tag

(with regex)

how i can do that?

tnx guys

Render controls from html string


Iam getting the below string in a variable"result" after xslt tranformation.
if i do Page.ParseControl(result) iam able to render controls to the page.
But the requirement is different.
I have 4 place holders in that aspx page.I need to bind div id="Section1" to placeholder1,
div id="Section2" to placeholder2 and similar the other two sections also  to the corresponding place holder.
Please help me out how can i loop and add controls to corresponding place holder.

result =

<div id="Section1" xmlns:asp="remove">
  <asp:Label id="lblSection1" runat="server" text="section1" />
  <asp:RequiredFieldValidator ErrorMessage="Mandatory Field-1" runat="server" ControlToValidate="txtNameSection1" />
  <asp:TextBox id="txtNameSection1" runat="server" />
<div id="Section2" xmlns:asp="remove">
  <asp:Label id="lblSection2" runat="server" text="section2" />
  <asp:RequiredFieldValidator ErrorMessage="Mandatory Field" runat="server" ControlToValidate="txtNameSection2" />
  <asp:TextBox id="txtNameSection2"

Call server control from HTML string


Hi you guys, is there any way to create a server control from html string, i mean in code behind i have a string like this:

string html = "<asp:CheckBox ID=\"CheckBox1\" runat=\"server\" />";

So how to insert it into aspx page and when the page is rendering, it convert my string as i write it own in the webpage
Hope you guys can help
Thanks in advance!

String Builder returning some extra characters



I've built a workflow item to set a variable to a combination of multiple fields through String Builder.

It seems to be adding a characters like  ;  and #  (see below) when the results are fed into a field.

Example:   20 Metronix ;#Dimensions Incorrect;#
It should read  20 Metronix Dimensions Incorrect
Any ideas on why this would occur?

Connectiong String For SharePoint List Using with Report Builder 3.0 ?


Hai Friends,

     I am Ali, I need to retrive the all lists in to Report Builder and need to prepare Report and need to deploy in Sharepoint Library.

1. I Configured Reporting Services in Sharepoint Integrated mode and Credentials are in Windows Integrated Mode not in Trusted acount. 

2. In Report Builder 3.0 Connection Type "Microsoft Sharepoint List"

3. Connection String 'http://<server name>/sites/<site name>' like this, when i test the connectinons getting this error (The current action cannot be completed. The user data source credentials do not meet the requirements to run this report or shared dataset. Either the user data source credentials are not stored in the report server database, or the user data source is configured not to require credentials but the unattended execution account is not specified.)

Please anybody help me to proceed next steps.



MD.Liakath ali

Multiline Dynamic String Builder in SharePoint Workflow Designer

I am wanting to insert a newline or carriage return, or whatever, between two dynamic lookups inside the construct 'Dynamic String Builder'. Is this possible? The purpose of this activity in my sequential workflow is to append or concatenate the notes from each step into a multi-line string. I update the current notes into avariable called 'notesVariable', and then push it into a SP column called 'All Notes'. It works, but looks messy. Is this a bass-ackwards approach? Is there a 'best practice' that would look nicer?

Add Runat server to all element in html string



I have one html string in DB like below

<div style="padding-left: 200px; padding-top: 20px">
        <div style="text-align: left;padding-top:10px">
            <input id="Text1" type="text" /></div>
        <div style="text-align: left;padding-top:10px">
            <input id="Text2" type="text" /></div>
        <div style="text-align: left; padding-top: 10px">
            <input id="Button1" type="button" value="Submit" /></div>


i wan to render this in aspx page. but before this i want to all runat server to all html control in above string


<div style="padding-left: 200px; padding-top: 20px">
        <div style="text-align: left;padding-top:10px">
            <input id="Text1" runat="server&

SQL: Stripping HTML tags from a string by calling a function



I have a function that strips HTML from a string. But it lies in a different database to the batabase that is being queried.

My question is: How do i call that function in my query?




remove unwanted parts of a string of html tags


hi,all, I have a string of tags like:

<A href

ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

This post covers another useful improvement in VS 2010 - HTML/ASP.NET/JavaScript snippet support. Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

Visual Studio has supported the concept of "snippets" for VB and C# in previous releases - but not for HTML, ASP.NET markup and JavaScript. With VS 2010 we now support snippets for these content types as well.

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend