Custom control - Property Value not retaining in ProcessRequest

Last post 06-28-2008 12:27 AM by Kalyanasundaram KC. 2 replies.

Sort Posts:

  • Custom control - Property Value not retaining in ProcessRequest

    06-27-2008, 6:20 AM

     Hi,

    Im trying to create one Custom Control for creating BarChart.

    I used IHttpHandler interface.

     

    1            private DataTable _dataSourceTable;
    2            public DataTable DataSourceTable
    3            {
    4                get { return _dataSourceTable; }
    5                set { _dataSourceTable = value; }
    6            }
    7    
    8            private string _dataValueFieldName;
    9            public string DataValueFieldName
    10           {
    11               get { return _dataValueFieldName; }
    12               set { _dataValueFieldName = value; }
    13           }
    14   
    15           private string _dataKeyFieldName;
    16           public string DataKeyFieldName
    17           {
    18               get { return _dataKeyFieldName; }
    19               set { _dataKeyFieldName = value; }
    20           }
    21   
    22   ..............
    23   ...............
    24   
    25          protected override void Render(HtmlTextWriter output)
    26           {
    27               output.AddAttribute(HtmlTextWriterAttribute.Src, "ChartCustomControl.axd?uid=" + this.MyUniqueID);            
    28               base.Render(output);
    29               
    30           }
    31   
    32           public void ProcessRequest(HttpContext context)
    33           {
    34               DataTable dt = _dataSourceTable;
    35               GenerateBarChart(context);
    36           }
    37   ...................
    38   ....................
    

      

    In the above code in line number 34, the value for _dataSourceTable is not retaining.

    Can anyone explain me how to solve this problem..?

     

  • Re: Custom control - Property Value not retaining in ProcessRequest

    06-27-2008, 3:43 PM
    • All-Star
      46,040 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Hi,

    is it's value set and read during the same request? If IsReusable property of IHttpHandler implementation is set to false, HTTP handler is instantiated for every request (usually the default and ensures that no mixup with the state occurs), have you considered this aspect?

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: Custom control - Property Value not retaining in ProcessRequest

    06-28-2008, 12:27 AM

    Hi Joteke,

    Im setting IsResusable to true like the bellow code; Should we set to false to get value or true itself correct..?

    1            public bool IsReusable
    2            {
    3                get
    4                {
    5                    return true;
    6                }            
    7            }  
    

    And i treid with true and false.. but still it is not retaining;
    And i have one button in my page. The image has to draw or save only when i click this button.
    But the control is drawing the image when the page is loading itself. Any idea why it is happening..?

Page 1 of 1 (3 items)