C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Passing value from codebehind page to .js file


Posted Date: 13 Aug 2009    Resource Type: Code Snippets    Category: Javascript
Author: MadhuMember Level: Bronze    
Rating: 1 out of 5Points: 5



When you run the program, A function in .js file executes and display value in popup window.


In Default.aspx page. inside body call the function and pass the value as shown

< head>
< script src="JScript.js" type="text/javascript">
< /head>
< body>
< form id="form1" runat="server">
< asp:Label ID="Label1" runat="server" Text="Label">
< script type="text/javascript">
dispcal(document.getElementById("<%=Label1.ClientID%>").innerHTML)
< /script>
< /form>
< /body>
< /html>


//in Default.aspx.cs
//codebehind page. Assign the value to some label
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "5";
}


//in JScript.js file
function dispcal(val) {alert(val);}



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Javascript  .  Codebehind to .js  .  Aspx to .js  .  .js  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Checkbox list validation
Previous Resource: Check box list validation through javascript
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use