Avatar of SiemensSEN
SiemensSEN

asked on 

How to register a script at the bottom of a page in C# code behind

Hello,
I the following script. How do i include it at the bottom of my page using code -behind in aspx.


 private string loadDropboxScript()
        {
              string key = ApiKeySettings.DropboxAppKey;
              StringBuilder sb = new StringBuilder();
              sb.Append("<script type='text/javascript' src='https://www.dropbox.com/static/api/2/dropins.js' id='dropboxjs' data-app-key=");
              sb.Append("'").Append(key).Append("'").Append("></script>\n");
              return sb.ToString();
        }

Open in new window

?
I tried to used  ScriptManager.RegisterStartupScript .
ScriptManager.RegisterStartupScript(this, this.GetType(), "dropboxdriveScript", loadDropboxScript(), true);

Open in new window


However, it  adds  the script but it place it within  another script type.. Is that valid?

<script type="text/javascript">
//<![CDATA[
<script type='text/javascript' src='https://www.dropbox.com/static/api/2/dropins.js' id='dropboxjs' data-app-key='mmmmmm'></script>

Open in new window


Here is what I tying to accomplish. I want to add dropbox.js to my page and a dropbox picker. However, this service is block in  some network.So, my page load for a while if Drop Box is not allow. I would like to only incur this penalty when the button is press or have include everything has been loaded

Thanks
JavaScript

Avatar of undefined
Last Comment
Alexandre Simões

8/22/2022 - Mon