let's have a look to my little dummy control again on this way it works, but is it the right way to work with a composite control? <ParseChildren(False, Nothing), PersistChildren(True)> _ Public Class CompositeTest Inherits CompositeControl Dim pnl As Panel Dim txt As TextBox Dim dde As AjaxControlToolkit.DropDownExtender Protected Overrides Sub OnInit(ByVal e As System.EventArgs) pnl = New Panel txt = New TextBox dde = New AjaxControlToolkit.DropDownExtender pnl.ID = "pnl" txt.ID = "txt" dde.ID = "dde" dde.TargetControlID = "txt" pnl.Controls.Add(txt) pnl.Controls.Add(dde) Controls.Add(pnl) MyBase.OnInit(e) End Sub Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) pnl.RenderControl(writer) End Sub End Class
Hendrik Debedts
Posts
-
Extender controls may not be registered after PreRender -
Extender controls may not be registered after PreRenderI'm currently developing a compositecontrol, there was something I didn't understand, so I decided to create a little control to reproduce the problem to find out why this problem occurs. When running the following code I get the error above. <ParseChildren(False, Nothing), PersistChildren(True)> _ Public Class CompositeTest Inherits CompositeControl Dim pnl As Panel Dim txt As TextBox Dim dde As AjaxControlToolkit.DropDownExtender Protected Overrides Sub OnInit(ByVal e As System.EventArgs) MyBase.OnInit(e) pnl = New Panel txt = New TextBox dde = New AjaxControlToolkit.DropDownExtender End Sub Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) pnl.ID = "pnl" txt.ID = "txt" dde.ID = "dde" dde.TargetControlID = "txt" pnl.Controls.Add(txt) pnl.Controls.Add(dde) Controls.Add(pnl) 'MyBase.Render(writer) End Sub End Class The question is why does this happen? And where in a control's lifecycle will a (extender-) control be registered?
-
Dynamically generated repeaters and the 'AddAt' methodI want to use the 'AddAt' method with a dynamically generated repeater. It doesn't work. It's just like the whole repeater has only one item because i only can add an item 'before' or 'after' the whole repeater. I use this ItemTemplate class Public Class clsNavigatieDetail1ItemTemplate Implements ITemplate Private mboOpgevuld As Boolean Private moRepeater As Repeater Private msNavigatieDetail1 As String Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn Try If Not mboOpgevuld Then mboOpgevuld = True Dim oDataTable As DataTable oDataTable = CType(moRepeater.DataSource, DataTable) For i As Integer = 0 To oDataTable.Rows.Count - 1 Dim sItem As String sItem = "<div class='NavigatieMenuDetail1'>" sItem += "<div class='divMenuCell3' class='NavigatieMenuDetail1'> </div>" sItem += "<div class='divMenuCell4'>" sItem += "<a href='javascript:doPostback();setNavigatieDetail1 (" + oDataTable.Rows(i)("IDSubNavigatie1").ToString + ");'>" sItem += oDataTable.Rows(i)("OmschrijvingSubNavigatie") sItem += "</a>" sItem += "</div></div>" Dim oLiteralControl As New LiteralControl oLiteralControl.Text = sItem container.Controls.Add(oLiteralControl) Next End If Catch End Try End Sub Public Sub New(ByVal oRepeater As Repeater, ByVal sNavigatieDetail1 As String) mboOpgevuld = False moRepeater = oRepeater msNavigatieDetail1 = sNavigatieDetail1 End Sub End Class
-
Accessing printer status informationI want to programatically access the printer status (usually get by printing off a status page). How do you do that? Greetz, Hendrik
-
DataGridViewComboBoxColumn Data ErrorI have a datagridview with a DataGridViewComboBoxColumn that contains items of self-builed types. When the selected value is changed i get a DataGridViewComboBoxColumn Data Error. Why does this happen?
-
Table variablesI'm writing a database class , I need to use a table variable from within .Net (C#), but it always gives an SQLException saying "Must declare the table variable '@Par1'." 1. I declared an SQLParameter object 2. I added the object to the 'Parameters' collection of the command How can I solve this
-
Exit For in C#?thx
-
Exit For in C#?What's the 'Exit For' equivalent in C#?
-
ReaderWriterLock [modified]By using this, what exactly is locked? A specifiek variable or the thread itself or the variables that have been modified with 'System.Threading.Interlocked.Increment'? I THINK 'THE VARIABLES THAT HAVE BEEN MODIFIED BY THE THREAD'. WRIGHT? If you have the following: public static void Synchronization_WriterLock() { System.Threading.ReaderWriterLock oReaderWriterLock; oReaderWriterLock = new System.Threading.ReaderWriterLock(); miCount = 0; try { oReaderWriterLock.AcquireWriterLock(100); try { System.Threading.Interlocked.Increment(ref miCount); Console.WriteLine(miCount); } finally { oReaderWriterLock.ReleaseWriterLock(); } } catch (ApplicationException e) { Console.WriteLine("Failed to get a Writer Lock"); } } What locks what? -- modified at 17:03 Wednesday 27th December, 2006
-
Sharing data across threadsThx
-
Sharing data across threadsConsider the following: namespace Lesson2 { class Program { static void Main(string[] args) { System.Threading.ThreadStart oThreadStart; oThreadStart = new System.Threading.ThreadStart(UpdateCount); System.Threading.Thread[] oThreads; oThreads = new System.Threading.Thread[10]; for (int i = 0; i < oThreads.Length; i++) { oThreads[i] = new System.Threading.Thread(oThreadStart); oThreads[i].Start(); } // Wait for them to complete for (int i = 0; i < oThreads.Length; i++) { /* * The different threads in 'oThreads' use the same * variable 'Counter.Count'. * => The variable 'Counter.Count' is shared by these threads. * * Without 'Join' the 'WriteLine' does his work before the * last thread is done. * => Total is less then 100.000. */ oThreads[i].Join(); } /* * Show to the console the total value of 'Counter.Count' *(after the 10 threads) * Should be 10 * 10.000 = 100.000 */ Console.WriteLine("Total: {0}", Counter.Count); Console.ReadLine(); } static void UpdateCount() { for (int i = 1; i <= 10000; ++i) { Counter.Count = Counter.Count + 1; } } } public class Counter { public static int Count; } } The expected 'Total' that is written to the console is '100.000' (10 threads that increment 'Counter.Count' with '10.000'). The book i'm currently reading (http://www.amazon.com/MCTS-Self-Paced-Training-Exam-70-536/dp/0735622779) says that if you run this code on a hyperthreading- or a multiprocessorsystem the 'Total' that is written to the console will sometimes be less than '100.000'. I don't understand the explanation.
-
ExecutionContextCan anybody help me to understand and use 'ExecutionContext' (or give me za good link)
-
System.Xml.Serialization.XmlSerializer [modified]By initializing an 'XmlSerializer' object, you must specify what type of object you will serialize. Any idea why you must do this by using an 'XmlSerializer' and not when you are using a 'BinaryFormatter' or any other formatter? -- modified at 7:00 Friday 8th December, 2006
-
'OptionalField' attributeS O L V E D By using 'BinaryFormatter', the .Net Framework 2.0 doesn't give an exception if you do not use the 'OptionalField' attribute. But if u use the 'SoapFormatter', the meaning of the 'OptionalField' attribute becomes clear.
-
'OptionalField' attributeStrange, I can't simulate an exception, what am i doing wrong? 1. Create a class 2. Create an object instance 3. Serialize this object 4. Add a field to the class (value or reference) 5. Deserialize (I supposed .Net would trow an exception here because there's a new field that isn't serialized, but it doesn't) I think it's just .Net 1.x that generate an exception -- modified at 4:58 Wednesday 6th December, 2006
-
'OptionalField' attributeThe meaning is writed as "If the member was not serialized, the CLR will leave the members's value null rather than throwing an exception." Visual Studio does the same thing as if this attribute was not used, so why should anyone use it? Or is it to garantee compatibility with .Net 1.x?
-
FileSystemWatcher questionIt's because a changed-event fires more than you probably expect, for example: - When you create a file - When you delete a file - When you rename a file - ...
-
InterfacecastingOh yes you can, this code compiles without any problem ;) Here you pass an object of a class who implements the System.Collections.ICollection interface (Person) to a method that has a System.Collections.ICollection attribute (static void aMethod(System.Collections.ICollection i)) namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Person oPerson = new Person("Hendrik Debedts"); aMethod(oPerson); Console.ReadLine(); } static void aMethod(System.Collections.ICollection i) { Console.WriteLine(i); } } public class Person : System.Collections.ICollection { public string msNaam; public Person(string sNaam) { this.msNaam = sNaam; } public override string ToString() { return this.msNaam; } public void CopyTo(System.Array array, int index) { } public int Count { get { int anInteger = 0; return anInteger; } } public bool IsSynchronized { get { bool aBoolean = false; return aBoolean; } } public object SyncRoot { get { object anObject = new object(); return anObject; } } public System.Collections.IEnumerator GetEnumerator() { System.Collections.ArrayList arl = new System.Collections.ArrayList(); return arl.GetEnumerator(); } } }
-
InterfacecastingYes ok, but if you can cast an object to an interface, it means that the class of the object implements the interface and when the class implements the interface you don't have firstly cast the object to the interface
-
InterfacecastingI know, but what is the need of doing this? Why should someone do this?