Which page event could be used for the following purpose?

77 views Asked by At

I have a page which is having the following

Some ddl's for Filter the data

  • A Submit button
  • A export Button
  • A GridView

In general We show/hide Export button if submit query results more than zero rows/ no rows

NOTE:

It is not only the case for one button but there would be more and i will have to check for the permission for every where i show /hide the buttons

For Example

Page_Load

showHideAsPerPermission(btnExport);


BtnSubmitClick()

if rows>0
    btnExport.Visible = true;
else
    btnExport.Visible = false;

But for the purpose of Permission

I want to set Export button visibility to true/false after BtnSubmit_click (or all controls events like selected index change, textChanged etc.) event has fired

A little Explanation of my problem

Say if you have permission to export then it only visible when rows>0 and if you don't have then it invisible even rows>0 but if i set the permission on page load and then i set exports visibility true for rows > 0 then it is visible even you don't have permission so is there any event which fires after control events

Is there any method which i can utilize for this purpose

I have read the following events and tried Page_Unload event which actually does nothing cause page is already rendered

So is there any method which could accomplish my task

enter image description here

Note:

As per my Knowledge there is no such Event so can i create a custom page event?

1

There are 1 answers

0
MikeSmithDev On

Just do it in Page_Load.

Keep in mind, on BtnSubmit_click, the page will post back, Page_Load is going to execute again (so you'll probably need something like if (!IsPostback)...), and then BtnSubmit_click.