Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-12-13
3
Medium Priority
?
279 Views
Last Modified: 2014-12-26
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
0
Comment
Question by:SiemensSEN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40497878
Why do you need to add it from the code behind?

If there's something you want to use from the code behind you can simply inject it with the server side tags :
<%=...  %>

Open in new window

0
 

Author Comment

by:SiemensSEN
ID: 40499094
Thanks for your response..

I have an application that uses dropbox. However, on some networks this application block. I want to check if dropbox in enable  and then add the script. Otherwise my application just 'hang' until timeout is reach
0
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 2000 total points
ID: 40499232
That validation is done in Javascript or server side?

If it's in Javascript just add it to the script before performing the action.
If it's server side, consider adding a flag on an hidden field for instance, that you can use client side to know if you can connect to Dropbox or not.

This way the script can always be there, and you can even move it to a js file like it should.
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question