asp.net - How to pass value to javascript from code behind page? -
i have web application want call 1 method on body onload method.
i have method
<body id="pageid1" onload="setupfeaturedproperty(1,['http://www.brightlogic-estateagents.co.uk/mrus/upload/918-1.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/918-2.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/918-3.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/918-4.jpg']);setupfeaturedproperty(2,['http://www.brightlogic-estateagents.co.uk/mrus/upload/665-1.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/665-2.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/665-3.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/665-4.jpg']);setupfeaturedproperty(3,['http://www.brightlogic-estateagents.co.uk/mrus/upload/38-1.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/38-2.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/38-3.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/38-4.jpg']);setupfeaturedproperty(4,['http://www.brightlogic-estateagents.co.uk/mrus/upload/122-1.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/122-2.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/122-3.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/122-4.jpg']);setupfeaturedproperty(5,['http://www.brightlogic-estateagents.co.uk/mrus/upload/1076-1.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/1076-2.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/1076-3.jpg', 'http://www.brightlogic-estateagents.co.uk/mrus/upload/1076-4.jpg']);">
and arguments of these method can change in after time.
i want pass argument when page loaded.
i have tried lot of method pass argument code behind page page it's not working. please let me know better solution this.
thanks
use this:
page.clientscript.registerstartupscript(this.gettype(), "myscript",getscript(),true);
and then:
private string getscript() { return "setupfeaturedproperty(etc,etc,etc);"; }
if using updatepanels use scriptmanager class instead of page.clientscript
Comments
Post a Comment