Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

external - In Javascript, is it possible to pass a variable into <script> "src" parameter? -


is possible in javascript pass variable through src parameter? ie.

<script type="text/javascript" src="http://domain.com/twitter.js?handle=aplusk" />` 

i'd twitter.js , see if "handle" passed before doing need , returning response originating page calling twitter.js.

i had created function in twitter.js did following:

function gethandle() {   var vars = [], hash, username;   var hashes = window.location.href.slice(window.location.href.indexof('?') + 1).split('&');    for(var = 0; < hashes.length; i++) {     hash = hashes[i].split('=');     if (hash[0] == 'handle')       username = hash[1];   }    return username; } 

the problem, , makes sense, window.location.href not going work on file i'm calling <script src="" />

thanks!

i can see 2 solutions here.

first: can process parameters on server twitter.js hosted, dynamically change js file. example, file is:

var handle = {{ handle }}; 

and server somehow processes file, replacing twitter.js template file dependent on request sent.

the second option set global variables on page twitter.js loaded, this:

<script type="text/javascript">     window.twitter_js_handle = 'aplusk'; </script> <script type="text/javascript" src="http://domain.com/twitter.js" /> 

and in twitter.js:

var handle = window.twitter_js_handle || null; 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -