Run Javascript after Server Side Code

  • Thread starter Thread starter Olivier
  • Start date Start date
O

Olivier

Hi,

Here is my challenge :

I have a linkbutton on my form that stays invisible while a variable is empty.

Another button is displaying a panel (set to visible), thus, on the same form.
That panel's save button will save some user entry to the database and make sure the variable mentioned above is not empty.

As the variable is not empty anymore, the linkbutton must be refreshed to be visible.
I found in this forum that I could call the JS _DoPostback('LinkButton','') to refresh it.

Can I call the JS after the Database Save ? As the Save code is server side code, How can I do it ?
If not possible, any idea ?

TIA,

Olivier.
 
In the server side click event of your first button, do your database save and then set the Visible properties of the buttons as needed.
I don't think you need javascript.
But if you do need javascript you might find the RegisterStartupScript method useful.
Here's more info:
http://msdn.microsoft.com/library/d...mWebUIPageClassRegisterStartupScriptTopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Hi,

Here is my challenge :

I have a linkbutton on my form that stays invisible while a variable is empty.

Another button is displaying a panel (set to visible), thus, on the same form.
That panel's save button will save some user entry to the database and make sure the variable mentioned above is not empty.

As the variable is not empty anymore, the linkbutton must be refreshed to be visible.
I found in this forum that I could call the JS _DoPostback('LinkButton','') to refresh it.

Can I call the JS after the Database Save ? As the Save code is server side code, How can I do it ?
If not possible, any idea ?

TIA,

Olivier.
 
Well, resolved it by setting to visible as you proposed.
As my form is a multi-panel form (some are hidden, some not), the findcontrol method is quiet tricky...
Works better when the control to be found's uniqueid is passed instead of its Id.

Thanks,

Olivier.
In the server side click event of your first button, do your database save and then set the Visible properties of the buttons as needed.
I don't think you need javascript.
But if you do need javascript you might find the RegisterStartupScript method useful.
Here's more info:
http://msdn.microsoft.com/library/d...mWebUIPageClassRegisterStartupScriptTopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Hi,

Here is my challenge :

I have a linkbutton on my form that stays invisible while a variable is empty.

Another button is displaying a panel (set to visible), thus, on the same form.
That panel's save button will save some user entry to the database and make sure the variable mentioned above is not empty.

As the variable is not empty anymore, the linkbutton must be refreshed to be visible.
I found in this forum that I could call the JS _DoPostback('LinkButton','') to refresh it.

Can I call the JS after the Database Save ? As the Save code is server side code, How can I do it ?
If not possible, any idea ?

TIA,

Olivier.
 
Back
Top