0

I have a website where I load a couple of ASP controls and then I want to call a codebehind function called foo.

After coming across this topic I learned about the events of the page life cycle. I tried almost every event that visual studio can offer, and the function foo was ALWAYS called before the rendering.

Basically what the function foo does, it displays (using Response.Write() method) a data from a DataSet type (a data which was loaded in the Page_Load function).

To be more specific, there's an asp:DropDownList that states how the user wants the data to be sorted. I want the data to be displayed after the asp:DropDownList and not ahead of it (the list has a default value).

Is there a way to do that? Either firing the function after the form is already rendered or after the last control (in this case, the list) is rendered or whichever way that this is possible.

Note: Remember that the data is not constant (not its size, nor its content, obviously), it is downloaded from a database each time and is written with Response.Write() (unless there's another way to write the data - a way that'll somehow make sure it is written after the list...?).

And by the way - Yes, I did see this post (nothing helped).

Community
  • 1
  • 1
Zach P
  • 1,731
  • 11
  • 16
  • You should not be using `Response.Write` to inject HTML into your Web Forms page. Instead, you should add a control such as a `Literal` after the list on your page, and add the HTML to that control. – mason Mar 31 '15 at 13:52
  • @mason Thanks a lot for the tip! I've actually been looking for some other way to do so – Zach P Mar 31 '15 at 13:53

1 Answers1

1

In the markup:

<form ...>
  ...
  <% foo(); %>
</form>
Igor
  • 15,833
  • 1
  • 27
  • 32