Click here to Skip to main content
15,900,384 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to hide horizontal scroll bar in listview Pin
amymarie319-Sep-06 9:08
amymarie319-Sep-06 9:08 
QuestionTreview Context menu shortcut keys Pin
Saamir18-Sep-06 9:58
Saamir18-Sep-06 9:58 
Questionerror 80040154 at instantiation of COM object Pin
mkrelli18-Sep-06 9:17
mkrelli18-Sep-06 9:17 
QuestionAdding data to an Array Pin
Saamir18-Sep-06 8:58
Saamir18-Sep-06 8:58 
AnswerRe: Adding data to an Array Pin
Guffa18-Sep-06 9:09
Guffa18-Sep-06 9:09 
QuestionShowing unused drive letters Pin
numbers1thru918-Sep-06 8:36
numbers1thru918-Sep-06 8:36 
AnswerRe: Showing unused drive letters Pin
Christian Graus18-Sep-06 12:47
protectorChristian Graus18-Sep-06 12:47 
QuestionVariable/Collection contents seems to change between calls Pin
jimbobmcgee18-Sep-06 8:16
jimbobmcgee18-Sep-06 8:16 
Sorry for the long post but I've been stuck on this for a while now and I'm hoping anyone can help.

I'm trying to make an ASP.NET usercontrol that renders 'buttons' (linkbuttons within table cells) that, when clicked, fire delegates. After having some initial problems with serialisation to ViewState, I have managed to make it respond to the click and fire the delegate, without issue.

The usercontrol has a private Hashtable that stores the buttons to render, which is persisted through ViewState, and a private IsDirty boolean that is set to false on initialisation and true if any changes are made to a button or the Hashtable. I expose the following methods to the rest of the app:

- RegisterButton(...) -> This adds to the Hashtable
- IsButtonRegistered(...) -> This queries the Hashtable

A button is a LinkButton that is dynamically generated, with a standard click event. The click event code retrieves the delegate and executes it.

As a test, I have a page with a usercontrol. This usercontrol registers a button on Load. The delegate for that button is also within this usercontrol. The delegate's job is to create another button if it is not already create. As such, the usercontrol's code is as follows:
<br />
private void TestUC2_Load(object sender, EventArgs e)<br />
{<br />
    DelegateButtons db = (this.Page as Default).DelegateButtons1;<br />
    if (db != null && !db.IsButtonRegistered("foo"))<br />
        db.RegisterButton("foo", "Foo", "dbutton", new ButtonAction(this.TestAction));<br />
}<br />
<br />
private void TestAction()<br />
{<br />
    DelegateButtons db = (this.Page as Default).DelegateButtons1;<br />
    if (db != null && !db.IsButtonRegistered("bar"))<br />
        db.RegisterButton("bar", "Bar", "dbutton", new ButtonAction(this.TestAction));<br />
}<br />

If I step into this code, I can see that the 'foo' button is created as it should be. If I click the button, the TestAction method is called as it should be, but while inside the TestAction method, the 'bar' button is already registered. As such:
                                                                   Hashtable
 1. Page loads for the first time                                  {}
 2. TestUC registers a 'foo' button                                {foo}
 3. Page is drawn                                                  {foo}
 4. ViewState is saved                                             {foo}
 5. User clicks 'foo' button                                       {foo}
 6. Page loads                                                     {}
 7. ViewState is loaded                                            {foo}
 8. Button click event is called                                   {foo}
 9. TestAction is called                                           {foo}
10. TestAction checks if 'bar' exists                              {foo,bar}
11. TestAction says 'bar' exists so doesn't recreate it            {foo,bar}
12. TestAction finishes, step returns to click event               {foo}

I'm really stuck as to why this could be -- can anyone help?

Regards,

J.
QuestionUnable to open shim database version registry key - v2.0.50727.00000 Pin
yarns18-Sep-06 6:40
yarns18-Sep-06 6:40 
AnswerRe: Unable to open shim database version registry key - v2.0.50727.00000 Pin
Rob Graham18-Sep-06 7:32
Rob Graham18-Sep-06 7:32 
QuestionConfirm Email Address Pin
yesufollower18-Sep-06 5:30
yesufollower18-Sep-06 5:30 
AnswerRe: Confirm Email Address Pin
Ed.Poore18-Sep-06 5:35
Ed.Poore18-Sep-06 5:35 
AnswerRe: Confirm Email Address Pin
Guffa18-Sep-06 6:07
Guffa18-Sep-06 6:07 
QuestionGUI optimization Pin
Scarsymmetry18-Sep-06 5:10
Scarsymmetry18-Sep-06 5:10 
AnswerRe: GUI optimization Pin
wheelerbarry18-Sep-06 5:32
wheelerbarry18-Sep-06 5:32 
AnswerRe: GUI optimization Pin
Rob Graham18-Sep-06 5:40
Rob Graham18-Sep-06 5:40 
AnswerRe: GUI optimization Pin
Not Active18-Sep-06 5:43
mentorNot Active18-Sep-06 5:43 
QuestionR/W in Microsoft Access Pin
CodeItWell18-Sep-06 5:03
CodeItWell18-Sep-06 5:03 
AnswerRe: R/W in Microsoft Access Pin
Rob Graham18-Sep-06 7:09
Rob Graham18-Sep-06 7:09 
Questionhow to display all the cells containing an certain letter and hiding the others in datagrid Pin
faladrim18-Sep-06 4:20
faladrim18-Sep-06 4:20 
AnswerRe: how to display all the cells containing an certain letter and hiding the others in datagrid Pin
wheelerbarry18-Sep-06 4:37
wheelerbarry18-Sep-06 4:37 
AnswerRe: how to display all the cells containing an certain letter and hiding the others in datagrid Pin
Alper Camel18-Sep-06 4:47
Alper Camel18-Sep-06 4:47 
QuestionRe: how to display all the cells containing an certain letter and hiding the others in datagrid Pin
wheelerbarry18-Sep-06 4:56
wheelerbarry18-Sep-06 4:56 
AnswerRe: how to display all the cells containing an certain letter and hiding the others in datagrid Pin
Alper Camel19-Sep-06 1:04
Alper Camel19-Sep-06 1:04 
GeneralRe: how to display all the cells containing an certain letter and hiding the others in datagrid Pin
faladrim18-Sep-06 20:36
faladrim18-Sep-06 20:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.