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

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

using replace with matches collection ??

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF

i need to be able to find a pattern, and then replace it with some other text that INCLUDES the original match.

For example, I'm looking for the pattern ABC=123... and wherever I find a match, i want to change the match to:

<a href=sometext>ABC=123</a>

Is there an easy way to do this? 


View Complete Post

More Related Resource Links

Can I replace the EntityObject as base-class in Entity Designer 3.5 sp1?


I'm using EF3.5sp1 for a project, and I've been working around many of its problems... as such, my entity partial classes have a lot of logic in them for change-tracking and whatnot.  Obviously, I'd like to factor this logic out into a common base class, but of course all my objects must derive from EntityObject.  Is it possible to tell them to derive from some class of my own invention (which would actually likely derive from EntityObject themselves)?

I'd rather avoid editing the EDMX file unless the changes will be safe on entity-model-update, since I'm still making changes to the database schema in this early state of my project.


Also, is there any good workaround for the fact that the change isn't tracked when you change EntityReference.EntityKey?

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it e


Here is the page directive for the page that throws the error:

@ Page language="c#" Inherits="University.AspNet.Index" CodeFile="Index.aspx.cs" %>

The code behind file Index.aspx.cs starts like this:

using University.Framework.UI;

namespace University.AspNet

public partial class Index : University.Framework.UI.HomePage

The code behind is extending this HomePage class, which is in turn an extenstion of another class University.Framework.UI.Page, which extends the System.Web.UI.Page class.

Am I misusing the I

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)


Hey guys

I came across this bug using while trying to implement a sitemap

Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148

Basic Instincts: Collection and Array Initializers In Visual Basic 2010


Collection Initializers are a great addition to the language and allows concise syntax in order to initialize both framework and user defined collection types.

Spotty Bowles

MSDN Magazine October 2009

Garbage Collection-Part 2: Automatic Memory Management in the Microsoft .NET Framework


The first part of this two-part article explained how the garbage collection algorithm works, how resources can clean up properly when the garbage collector decides to free a resource's memory, and how to force an object to clean up when it is freed. The conclusion of this series explains strong and weak object references that help to manage memory for large objects, as well as object generations and how they improve performance. In addition, the use of methods and properties for controlling garbage collection, resources for monitoring collection performance, and garbage collection for multithreaded applications are covered.

Jeffrey Richter

MSDN Magazine December 2000

Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework


Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory. However, you'll want to understand how it works. Part 1 of this two-part article on .NET garbage collection explains how resources are allocated and managed, then gives a detailed step-by-step description of how the garbage collection algorithm works. Also discussed are the way resources can clean up properly when the garbage collector decides to free a resource's memory and how to force an object to clean up when it is freed.

Jeffrey Richter

MSDN Magazine November 2000

How to Cache System.Collection.Generic.List object


I need to cache System.Collection.Generic.List object with expiration time

var Root = from feed in feedhotel.Descendants(ota + "HotelContent")
                           where (feed.Attribute("HotelCode") != null)
                           select new xmlhotel()




return Root.ToList();

Is it possible to cache Root.ToList() for some time....

Finding a control from a control collection



I'm trying to write a bit of code that will format all the numeric values in lables in my gridview. here's what i am doing right now:

On the RowDataBound Event, i create a row object for the row that is currently being bound.
then i go use the FindControl method to grab each label by name.

Problem is there's too many columns in this table and i really dont wnat to have to type it all out. Here's an example of what i am currently doing

' Get row being bound
Dim myRow = e.Row

' Get labes to be formatted
Dim lblMunicipalIncineration = CType(myRow.FindControl("lblMunicipalIncineration"), Label)

' format labels
If lblMunicipalIncineration IsNot Nothing Then
    If Not String.IsNullOrEmpty(lblMunicipalIncineration.Text) Then
        lblMunicipalIncineration.Text = FormatNumber(lblMunicipalIncineration.Text, 0, TriState.False, TriState.False, TriState.True)
    End If
End If

Can i use myRow.Controls to grab a list of all the controls and then somehow get a list of all labels in the collection and then use a for loop to go through and format each label?

Multiple services in REST Collection WCF Service?


After I create a "REST Collection WCF Service" project, it contains one service "service.svc". Can I add multiple services to this project? There must be a way to do so. Otherwise, it does not make sense to create one project for each service.


My question is how to add a new service to an existing "REST Collection WCF Service" project?


Thanks a lot.

Site Collection Usage Summary: No Data Available


Usage analysis processing is enable for my farm in both Central Administration and in the SSP.

I've checked TImer Job Status and the three timer jobs responsible for doing the log analsis are all running.

I've also checked the log file locations and the log files are being generated.

Yet when I browse the "Site collection usage summary" report (SpUsageSite.aspx) I get the following:

No data is available for this report. Usage analysis might have been enabled only recently, or there might have been insufficient usage to result in any values for the report.

My farm is running 2007 Enterprise SP2 (

Can someone confirm if this issue was fixed with one of the CU's that were issues post-SP2?

Site Collection Usage Report Include Outlook?


Hi all,

Does anyone know if the Site Collection Usage Report includes activity that occurs from Outlook? For example, if a user contributes to a discussion board without ever physically touching the site or if the user just reads list content from Outlook, is this included?

ANY help at all is greatly appreciated.


Regex.replace [h2] to


I try to replace [h2] to <h2>
I use this coding:

string o = "<h2>test</h2>";
o = Regex.Replace(o, "[h2]", "<h2>");
o = Regex.Replace(o, "[/h2]", "</h2>");


But the result after the first regex is:


So that is not what i want.
After the first 1, he should make:


Whats wrong?

Filtering a grid column when the column is bound to a collection


My SetUp (I am using EF for my data):

1 Grid bound to a collection of Vehicle Objects

1 Combobox with multiselect enabled bound to a list of VehicleExtras.

Each vehicle has a collection of extras. 

My Problem:

What I need to do is have the Grid filter Vehicles based on whether those vehicles have the selected VehicleExtras from the Combobox

Can anyone point me in the right direction as to how this filtering should be done (if it is at all possible!)



Linq query results to List collection



I have a GridView in my page. I want to use below code in code beind. query nothwing DB using linq . add linq query result to new list and then bind list as gridview Datasource

I use below code . But I don't know how to add results to List? Could any one tell me how !

Public Class OrderCity
        Private _name As String
        Private _city As String
        Public Property name As String
                Return _name
            End Get
            Set(ByVal value As String)
                _name = value

            End Set
        End Property
        Public Property city As String
                Return _city
            End Get
            Set(ByVal value As String)
                _city = value

            End Set
        End Property
    End Class
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim dbe As New SFFAV1DataContext
        Dim latestadsDs = From p In dbe.Products _
                            Select New With {p.Title, p.ProducedCity} _
                             Take (2)

        Dim FilteredList As New List(Of OrderCity)()
        For Each result In latestadsDs
            Dim Menedfcou = Nothing
            FilteredList.Insert(0, Menedfcou)

The new SortedSet Collection in .NET 4.0


With the newest release of .NET Framework, version 4.0 - the class library provides new collection set from System.Collections.Generic classes called SortedSet<T>.

The two main features of SortedSet<T> are:

Duplicate elements are not allowed
Maintains a sorted order as elements are inserted or deleted without affecting the performance
In order to make all this clearer, lets pass through the tests that I've made.

Test 1: Create sorted set and print all elements (the default behaviour showcase)

var sortedSet1 = new SortedSet<int> { 5, 9, 11, 1, 44, 21, 3, 2, 9}; 

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