Click here to Skip to main content
13,446,310 members (36,968 online)
Rate this:
Please Sign up or sign in to vote.
<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 />

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 29-May-12 2:31am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

hidden field is a good solution
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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
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 control
also accessible in 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180314.2 | Last Updated 29 May 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100