Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Void firing before changes

I've got an asp.net page with a void that I run whenever one of two dropdowns chages. It does some counting and sets the datasource of a gridview for me. It's doing what I want...almost.

The problem is I've got some parameters which I attempt to set before I call it (UserName, Start and End Date). But, they don't actually change until after it runs. That happens on page_load and in any postbacks.   "On paper" my parameters are changed first. Bottom line, my counts and gridview appear to be one step behind.

I can get something almost right setting the void to run on an selected value changes in the two dropdowns, but my load event doesn't work that way.
0
jdcollins21
Asked:
jdcollins21
1 Solution
 
David H.H.LeeCommented:
Hi jdcollins21,
How you invoke the Postback code in page_load event, through client script or server script?
You can put the existing controls inside <asp:updatepanel>, call from Page_Load event(code behind).
eg:
Private Page_Load(){
  if(!IsPostBack){
    CallDropDownSelectedIndexChanged_Event(null,null);//call your selectedindexchanged event
  }
}

Or, you can call the client script manually.
<script language='Javascript'>
__doPostBack('__DrpDownListID', 'YourCustomArgument');
</script>
Sample:
http://www.dotnetspider.com/resources/1521-How-call-Postback-from-Javascript.aspx

But, this is depending how your control your flow and the way you invoke the script based on your real situation.
Please provide more details if you seek any further assistance.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now