Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
ASP.NET
<asp:Button ID="Button1" runat="server" Text="Lunch" CausesValidation="false" CssClass="bigbuttons" style="background:url(../App_Themes/Images/green-box.gif)" Font-Bold="True"  ForeColor="White" Font-Size="Large" OnClientClick="openmodalWin(); return false;"  /> <br />

JavaScript:-
JavaScript
function openmodalWin() {
        var CloseTImeOfPopUp = window.showModalDialog("ClockPopUP.aspx", "Clock", "dialogWidth:550px;dialogHeight:350px,");
        }

As you can see that i m calling a javascript function "openmodalWin" on the Button Click event .I had checked that the function is returning CloseTimeofPopUp sucessfully and i am able to display it via Alert box. I want that the reurn value from the javascript function, i can store on the same server side code i.e. Button1_OnClick() event and then i can store it to database. Please tell me how i can do this ?
Posted

hidden field is a good solution
but
other than hidden field, if picking value is not very urgent or you need this value across multiple pages. inside JS you can save the value in Session as well and pick the value on last postback where you need to pick this value and save in database
 
Share this answer
 
when you got value of time by js in your variable
you can set it into a hidden field

and remove "return false" from your button
and add OnClick event on that button (by double click on button a event added in cs page)

after that hidden field value can be access in Asp.Net Page
 
Share this answer
 
Comments
Dharmenrda Kumar Singh 29-May-12 9:01am    
I had done as per your guidance, I had created a hidden field and set the value to that hidden field. Then i removed "return false" from the button but and i also created the OnClick event also and added string lunchelapsedTime = Request.Form["hiddenLunchElapsed"]; but when i debug it is showing null.
Technoses 29-May-12 12:22pm    
you should add a hidden control of asp.net control
also accessible in asp.net page
Dharmenrda Kumar Singh 30-May-12 2:07am    
It works...Thanks

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