.net Usercontrol Vs Customcontrol Vs Stringbuilder?

Dec 22, 2010

I'm building a product catalog which displays between 50/100 products per page.Since I want to have different browse sections on my site I've put each product into a UserControl. Well, not the products themselves ofcourse, but some labels, divs and images. I then set its properties in run-time when processing the database results. So the advantage is that I only have to change the product control at 1 place for the whole site. I'm putting the controls in a page using LoadControl in a loop.

However the pages are not loading quite as fast as other pages which process the same db query and output the same html using a StringBuilder. And since I want my site to perform well if/when it receives some decent traffic I'm worried about this. I haven't done any benchmarkings yet but I clearly see the difference. My questions to you is 'Are there any alternatives which are faster then using LoadControl with a customcontrol but are easily maintained (or atleast in 1 location)?'I was thinking of:

Creating a customcontrol (although I've never done it and don't know 100% if this will speed things up)Continue with the StringBuilder method and put the CreateProduct in my base class

[edit]Code[/edit]

I don't have the excact usercontrol code here but I will edit this post when I get home..but here is the simplified idea:

1) Getting my database result (using Subsonic 2.2 as my DAL)

DAL.ProductCollection coll = new DAL.ProductCollection();
if(coll.count > 0)
{
foreach(DAL.Product item in coll)[code]....

My usercontrol itselves just consists of 3 Literal controls and 1 Image control.

View 4 Replies


Similar Messages:

Custom Server Controls :: UserControl With ListView To CustomControl?

Jun 16, 2010

I have created lots of UserControls, but never tried CustomControl.Recently i created a Photo Gallery UserControl using Listview & Visual LightBox.Now i want to publish it as CustomControl.Here is my UserControl's code :

<link rel="stylesheet" href="LightBoxGallery/css/vlightbox.css" type="text/css" />
<style type="text/css">
#vlightbox a#vlb

[code]...

View 1 Replies

Web Forms :: How To Write Event For Dropdownlistbox Customcontrol

Mar 3, 2010

using delegates how to write event for dropdownlistbox customcontrol in asp.net

View 3 Replies

Custom Server Controls :: How To Create A CustomControl With A Template File

Apr 18, 2010

I saw some CustomControls using a separated ascx file, it rendered the ascx file (the template) but all the code was in a dll (the control).How can I do that? Can someone post a Hello World example?

View 6 Replies

Is Stringbuilder Datatype

Dec 2, 2010

Is StringBuilder a datatype?

View 9 Replies

Trimming Commas From The End Of A Stringbuilder?

Jan 22, 2010

I've a string builder, and I need to convert it to a string, and then trim any commas if there are any there (I need to get rid of them because I'm building an sql query).

Here's what I'm doing:

myStringBuilder.ToString().TrimEnd(',');

Why isn't this working??? It's not trimming any commas at the end!

I'm using c# :)

View 9 Replies

StringBuilder - Get Information On Two Lines?

Jul 9, 2010

I have a message on one and I'm sending that message to another using a Session. The problem is the message come out on one line, please code

[Code]....

Output: --- Original Message ---message for the user.

Output should be:

Original Message

message from the user. How do get the info on two lines?

View 10 Replies

How To Clear A String And Stringbuilder

Jan 25, 2010

How do I delete or clear a string? Preferable delete...

So far I've tried:

myString.TrimEnd(0, myString.Length);

myString.Remove(0, myString.Length);

myString = null;

None of the above work...

Also- how do i clear a stringbuilder? Is it in the same way?

I'm using c# and working in Visual Web Developer.

View 13 Replies

C# - How To Make StringBuilder Empty Again

Jul 12, 2010

I have a loop where i create some string value based on certain conditions. I did place StringBuilder object outside of the loop and each time i have new row in loop i need to clear StringBuilder appended values for this row.

How do i clear those?

[Code]....

View 5 Replies

Display An Image Using The Stringbuilder In C#.net?

Mar 24, 2010

How to display an image using the stringbuilder in C#.net

View 6 Replies

C# - StringBuilder.Append With Float?

Jan 12, 2010

StringBuilder.Append using float is truncating the value. What is it converting to and how can I stop it from truncating?AttributeOrder is type float and I am losing precision when building the string.

if ( AttributeOrder != 0 )
{
if ( Result.Length > 0 )

[code]...

View 5 Replies

ADO.NET :: StringBuilder Error - Append Datatable?

Nov 20, 2010

Actually I am wishing to use StringBuilder to Append DataTable as given below:

[Code]....

correct the line sb.Append(dt.Rows[i].Item(k, DataRowVersion.Current).toString()); to eliminate the following error:

'System.Data.DataRow' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of the type 'System.Data.DataRow' could be found (are you missing a using directive of an assembly reference?).

View 3 Replies

DataSource Controls :: Map Stringbuilder With Varchar?

Feb 12, 2010

Im developing a web application in asp.net where i have gridview with some text box controls in it.In runtime we are creating a new row dynamically by clicking add button .To insert data into the database.i used a stringbuilder instead of string becoz the data what i have to insert into database is more.but i am gettin the following error No mapping exists from object type System.Text.StringBuilder to a known managed provider native type. in database the datafield column datatype is varchar(max).

View 3 Replies

Using Stringbuilder To Call A Package That Contains A Function?

Mar 3, 2011

[Code]....

basically the name of my package is pkg_test and it is in the finance schema and the name of the function in the package is called get_nameHowever everything I run that function, it is gives me an error.

View 5 Replies

Pass A Stringbuilder Info To A Label?

Feb 16, 2010

i have a stringbuilder which loops thru the items details of my shopping cart like below:

StringBuilder sbo = new StringBuilder();
for (int i = 0; i != Cart.Order.Items.Length; ++i)
{
sbo.AppendLine(
string.Format(
"{0} {1} {2} {3} <br />",
Cart.Order.Items[i].ItemNumber,
Cart.Order.Items[i].ProductTitle,
Cart.Order.Items[i].Size,
Cart.Order.Items[i].Price.ToString("c")
)
);
}

now i would like to bind these details to 4 labels like lbItemno, lbProdTitle, lbSize, lbPrice.

View 4 Replies

C# - Dynamically Create Controls Using Stringbuilder?

Mar 12, 2010

i have been trying to create controls dynamically on my web page using the StringBuilder class..and i dont quite seem to get through...

i am trying to do this...

StringBuilder sbTest = new StringBuilder(string.Empty);
sbTest.Append("<input type="text" id="txt1" runat="server" />");
Response.Write(sbTest.ToString());

The page for sure displays a TextBox on the browser which is easily accessible through JavaScript...but what i want is the control to be available on the Server Side too...so that when the page is posted back to the server i can easliy obtain the value that has been entered by the user into the textbox.

View 4 Replies

Web Forms :: StringBuilder - Image Not Displaying In PDF

May 24, 2012

I am converting HTML to Pdf using StringBuilder .. added one image using

Doc theDoc = new Doc();
System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
sbHtml.Append("<html>");
sbHtml.Append("<body>");
sbHtml.Append("</table></td> <td width='406' height='104'><div align='right'><img src='~/images/logo.jpg'

[Code] ....

Here image is not displaying in PDF ....

View 1 Replies

UpdatePanel Dynamically Loaded Web UserControl Will Disappear After Clicking Any Button Inside The UserControl?

Mar 17, 2011

I've a ASP.Net page (Default.aspx) which will load UserControl (ucontrol.ascx) dynamically into an UpdatePanel. By using UpdatePanel, we believe we're able to prevent the entire page to be posted-back.

My problem is, within the UserControl, we have some form controls, such as inputs and buttons; after the UserControl is loaded, clicking on any button inside the UserControl will cause the UpdatePanel to be blanked. During the investigation, I found that, breakpoints within the Button1_Click() in the code-behind for the UserControl is never reached. Please reference to the code below, this references to [REFERENCE]1.

[code]....

View 2 Replies

Forms Data Controls :: UserControl Within Gridview Loses Properties When Usercontrol Events Are Trigered

Jul 17, 2010

This is page load

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ [code]...

But in my ascx.cs when IButton1_Click is trigered My name is null

private string _sname;
protected void Page_Load(object sender, EventArgs e)
{ [code]...

View 2 Replies

AJAX :: Nested UserControl With UserControl Disappears On Partial Postback

Jan 28, 2011

I have a page with an UpdatePanel with a UserControl in it. That UserControl contains a GridView with a nested UserControl that seems to disappear when the parent UserControl is rebound. I cannot for the life of me figure out why the child UserControl disappears. The code works beautifully on the first load, but any partial postback causes the "Pick" UserControl to disappear.

[Code]....

View 5 Replies

Web Forms :: Usercontrol Constructor Parameter - Unable To Pass The Value To Usercontrol?

Apr 6, 2010

im creating site with usercontrols. I have repeater, inside it is another repeater with usercontrol. My problem is passing BindedValue to usercontrol.Bindings works fine and binds the value i need but it cannot pass the value to usercontrol. When i type it manually it works, when i bind it, it passes null (!).I've tried get,set, functions (ondatabound, onload, oninit), accessing control from code with no luck. Ive read and tried to do all the google solutions but with no luck. (even with creating usercontrol inheritance)

View 5 Replies

Web Forms :: StringBuilder - Check Ticked Checkbox And Get Value?

Jan 18, 2010

if i change the code and put checkbox between the <td> tag. when i click the save button, how can i check the ticked checkbox and get the value of the CHECKBOX_1 in cs?

[Code]....

View 5 Replies

Web Forms :: Use Stringbuilder When Concatenating More Than 2 Strings - Performance?

Jul 2, 2010

I have been led to believe that the performance benefits of using StringBuilder over normal concatenation means that you should always use stringbuilder when concatenating more than 2 strings. However when I test them this does not seem to be the case. Take these 2 methods

public void TestMethod5()
{
for (int i = 0; i < 1000; i++)
{
string t = string.Empty;
t = "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd" + "dddddddd"; ;
}
}
public void TestMethod6()
{
for (int i = 0; i < 1000; i++)
{
StringBuilder sb = new StringBuilder();
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
sb.Append("dddddddd");
string t = string.Empty;
t = sb.ToString();
}
}

TestMethod5 takes 0.03 milliseconds so complete but TestMethod6 takes 1.43 milliseconds What is going on?

View 3 Replies

How To Display StringBuilder Objects As Well As Arraystring In Alert Box

May 14, 2010

when we store more than one string in arraystring or in stringbuilder class objects.then how can we print it on alert box in asp.net

View 1 Replies

How To Save Stringbuilder Contents Into SQL DB Image Field

Mar 25, 2011

in my webapp I've created and populated a stringbuilder for a csv file. Normally I write it directly to the response object for the user to download through the browser.However, now I want to save it to a SQL DB image field. Is there a direct way to stream it in? Or do I have to save it to file first, then read it back in?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved