Question

I think i'm missing something. What is the proper way to display an html div, for example, if the actual condition is met using Page_Onload + isPostBack + asp:button as a trigger for the event as following:

Page_Load -> Click event fired

Page load - element(a dynamically generted string for multiple table rows in this case) status hidden

Client click submit button:

Element toggled to visible.

 protected void Page_Load(object sender, EventArgs e)
 {
    if (!Page.IsPostBack)
    {
      nothing yet
    }
    else 
    {
      suppose to check on client event handle by asp button
    }
 }

// So here is the event fired by client

protected void imgButSbmt_Click(object sender, ImageClickEventArgs e)
{
    initializeReportTable();
}

and suddenly while trying to make sure I am correct with this argument,

I could see that imgButSbmt_Click is not "hitting" (with break Point attached while in debugging mode).

So first... I could note at this time that it's an unusual behavior (and while I am writing this question supposbly related to all my projects, this one was not firing at all events, so I solved it by deleting the solution file as I was writing this post).

So now, it does work.

BUT... this time (while solution is not yet to be Created) I re-opened my website "project" via File-Open-Website.

Hit F5 ...break Point works fine in red color.. no explanation marks this time. However, all events from the button & Drop down List that are configured to AutoPostBack

protected void DDL_Month(object sender, EventArgs e)
{
    initializeReportTable();
}

were not firing. All events except for Page_Load are firing now. After checking again it does fire but only on the second time!

What is happening here?

I remembered some readings I came across awhile ago that said I should check the autoeventwireup and make sure it is set to true (it's the default I think).

So these are the page directives:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Here is an example of a control DropDownList + imgButton within a table:

                    <td>
                    <asp:DropDownList ID="DDL_Month" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDL_Month"></asp:DropDownList>
                    </td>

                    <td>
                    <asp:ImageButton ID="imgButSbmt" ImageUrl="images/sendreq.png" 
                        runat="server" Height="25px"  OnClick="imgButSbmt_Click"
                        style="margin-right: 0px; border-width:" />
                        </td>
Was it helpful?

Solution

as sugested by @JonH , and as a solution i've already had to use in some other even bugier scenario if you're experiencing any UCB (un identified Code Behavior)... just do as follow

1) open a new folder as a new home for the project Work-folder

2) copy all sub folders from The Buggy project, such as images, js etc'

3) Create a new webSite / any other application you had unusual problems with

then just apply all references needed for the application , copy codes to newly created .cs/vb/aspx accordingly , use exisiting items (your other classes that are in separeted files)

and now you're ready to continue working...

the bugs should be behind you by now

just don't forget to delete the old project and any solutions files associated with it.

hope it will help some of other fresh developers who also encounterd the U.C.B Phenomenon

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top