Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript
<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:-
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
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
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
  Permalink  
Comments
Dharmenrda Kumar Singh at 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 at 29-May-12 12:22pm
   
you should add a hidden control of asp.net control
also accessible in asp.net page
Dharmenrda Kumar Singh at 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
0 OriginalGriff 298
1 Sergey Alexandrovich Kryukov 181
2 Yogesh Kumar Tyagi 165
3 ChauhanAjay 156
4 Richard Deeming 150
0 Sergey Alexandrovich Kryukov 6,218
1 OriginalGriff 5,413
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 29 May 2012
Copyright © CodeProject, 1999-2014
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