Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I have a javascript function in aspx page
XML
<script type="text/javascript">
    function assignpwd() {
        var abc = document.getElementById('<%=Txtpwd.ClientID%>').value;

        document.getElementById('<%=Password1.ClientID%>').value = hex_md5(abc);
        return true;

    }


This is hidden fields used in function..

XML
<asp:HiddenField ID="Password1" runat="server" />
     <asp:HiddenField ID="Txtpwd" runat="server" />



I want to call this function in my c# page on page load event.


Thanks
Srishti
Posted

Try this
<body  önload="assignpwd()">

Refer: event_onload[^]
 
Share this answer
 
v3
Comments
VICK 30-Jun-14 3:35am    
The OP wants it from serverside Page Load. @Peter Leow.
srishti_ 30-Jun-14 3:38am    
i used this but it works on page load and in this time HiddenField Txtpwd has no value it is assign later in code
VICK 30-Jun-14 3:50am    
are u assigning the value to hidden field in the page load method or where??

Do try my pasted solution below(the last link ) and call the JS function after assigning value to hidden field.
Use the below code in serverside

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "assignpwd();", true);
 
Share this answer
 
To call a javascript function from serverside you can use

ScriptManager.RegisterClientScriptBlock Method

for details you can have a look at HERE.

Further the following link can help you with an working example.

Call From ServerSide..

and this one as well.

Hope it will help. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900