locked
Custom control - Property Value not retaining in ProcessRequest RRS feed

  • Question

  • User-416249946 posted

     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..?

     

    Friday, June 27, 2008 6:20 AM

All replies

  • User2032526919 posted

    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?

    Friday, June 27, 2008 3:43 PM
  • User-416249946 posted

    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..?

    Saturday, June 28, 2008 12:27 AM