JavaScript - Retaining the value of selected radion button when page reloads

Asked By anil namburi
17-Sep-10 02:48 AM
i have two radio buttons in my application, 1.yes 2.no by default 'no' is selected .when clicking on yes button it will display two more fields like starting date and ending datewith default values and user can change this values also.I have another button "ASV" when clicking on this another page will open and i will select one value in that and that value will appear in before page.Then that "radio buttons" page is refreshing and again "no" is selecting even though user selected "yes" button.so,I want to retain the value of selected radio button even though page refreshes or reloads... 

please provide solution in java.

thanks.
  Anand Malli replied to anil namburi
17-Sep-10 03:02 AM
Hi Anil,

Javascript is client script right, so when ever your page is submited to your server, you controls will reload again so if you need some hack...you can create server side radio button only so it will automatic maintain state for you make sure you place AutoPostBack="True"

let me know
Thxs
  anil namburi replied to Anand Malli
17-Sep-10 03:16 AM
thanks for ur reply,
But i need to know where to use AutoPostback="true.please provide solution with example.
  Anurag replied to anil namburi
17-Sep-10 03:24 AM
Make sure u have put ur code in:

 if(!Page.IsPostBack)
{

ur code here, so that radio button takes default value as false first time only.

}
  Anand Malli replied to anil namburi
17-Sep-10 03:30 AM
Hi Anil,

Put little effort to know it...its just there in your control only ...see the below code

<asp:RadioButton AutoPostBack="true" runat="server" Text="Yes" GroupName="grp" />

i hope you got it now

Thanks
  anil namburi replied to Anand Malli
17-Sep-10 03:40 AM
Thanks for ur reply,
        Iam working in spring frame work in java.So, please provide solution in java code.
Thanks.
  Anurag replied to anil namburi
17-Sep-10 04:12 AM
HAHAHA really funny coz this site is for .NET developers. But u can also store selected value in hidden field if available in java or any variable which stores value between post back.
Similar post here see this:
http://www.eggheadcafe.com/community/aspnet/17/10170830/retain-the-value-of-radiobutton-list-on-autopage-refresh.aspx
  Anand Malli replied to anil namburi
17-Sep-10 04:19 AM
i am sorry to say but i know nothing about CORE JAVA...
Create New Account
help
and convert problem . . i give my code for below i read the exp_date and that date compare to system date how to use anybody help me. . . . . . . . . . . SqlCommand c = new SqlCommand("select contact_no, exp_date from masterchauffer Hi, you can use CompareValidator eg < asp:CompareValidator ID = "CompareValidator1" ControlToValidate = "txt_DOB" Operator = "LessThan" Type = "Date" runat = "server" ErrorMessage = "Entered date must be less than current date" ValidationGroup = "Add" > < / asp:CompareValidator > / / same validation group should be added in the button control in which click the validation should be called / / You should also write the below code in page load CompareValidator1.ValueToCompare = DateTime.Now.ToString( "MM / dd / yyyy" ); this is the RangeValidator eg < asp:RangeValidator ID = "RangeValidator2" runat = "server" ControlToValidate = "txtedate" CultureInvariantValues = "true" ErrorMessage = "End Date is greater than Current Date" ValidationGroup = "Add" Type = "Date" MinimumValue = "2010-01-01" MaximumValue = "2010-12-31" > < / asp:RangeValidator > or
you can bind data in gridview by following step::: 1. Put gridview control in aspx page see <asp:GridView ID = "grdData" runat = "server" AllowPaging = "True" AllowSorting = "True" AutoGenerateColumns = "False" Width = "95% and bind it to gridview see below / / DGFTConnectionString from web.confid / / put this code in page load event and run it. . it will bind data into gridview DataTable ds = new DataTable DataBind(); Happy Coding thanks let me check Hello Pradeep, Here is the Gridview databind HTML Page: gridview . aspx <%@ Page Language = "C#" AutoEventWireup = "true" CodeFile = "Default.aspx.cs" Inherits = "BasicGridView" %> <!DOCTYPE html PUBLIC "- / / W3C / / DTD xhtml11.dtd "> < html xmlns = " http: / / www.w3.org / 1999 / xhtml " > < head runat = "server" > < title > Untitled Page< / title > < / head > < body > < form id = "form1" runat = "server" > < div > < asp:GridView ID = "GridView1" runat = "server" > < / asp:GridView > < / div > < / form > < / body > < / html > Here is the Code Behind Page Code: gridview.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections using System.Web.Configuration; using System.Data.SqlClient; public partial class BasicGridView : System.Web.UI.Page { protected void Page_Load( object sender, EventArgs e) { if (! this .IsPostBack) { string connectionString = WebConfigurationManager.ConnectionStrings[ "Northwind the argument to accomplish this. dAdapter.Update(dTable); Hope this helps you better. Thank you Anil protected void Page_Load( object sender, EventArgs e) { if (!IsPostBack) { bindGrid(); } } void bindGrid() { SqlDataAdapter da = new
first column of the Outter ListView. . I was unable to find good example. Thank you Anil Source code? If you add your controls dinamically to your page, don't forget to add them under the page OnInit otherwise their even't won't be fired. Morzel here is source code from asp.net page: < asp : ListView ID = "lv" runat = "server" DataKeyNames = "MonthInt" > < LayoutTemplate > < table id = "orders" cellpadding = "0" cellspacing runat = "server" id = "itemPlaceholder" / > < / LayoutTemplate > < ItemTemplate > < tr id = "row" runat = "server"> < td > < / td > < td > <% # Eval( "Date" )%> < / td > < td > <% # Eval( "PJM WH" , "{0:c}" )%> < / td > < td > <% # Eval( "INTERNAL_HUB" , "{0:c}" )%> < / td > < td 1951 -6.6074 Sep 9 3.3473 3.0104 8.5055 The Inner ListView Datatable: Date PJM WH INTERNAL_HUB NYJ 1 / 1 / 2010 -8.3898 -1.4005 -1.4942 1 / 2 runat = "server" id = "itemPlaceholder" / > < / LayoutTemplate > < ItemTemplate > < tr id = "row" runat = "server"> < td > < / td > < td > <% # Eval( "Date" ) %> < / td > < td > <% # Eval( "PJM WH" , "{0:c}" ) %> < / td > < td > <% # Eval( "INTERNAL_HUB" , "{0:c}" ) %> < / td > < td
implement "Download as Word Document" functionality for a report with customized features, through a web page without using any third party utility. Among other things, I had to allow users to interesting to see how an Office Document renders HTML & CSS on thus saving as Web page. By understanding and emulating this conversion technique, we can generate Word or Excel documents through Just to demonstrate that we will be streaming dynamic content, I will be showing the date & time at which the page is accessed with DateTime.Now Finally by setting the MIME type to application / msword using be forced to be downloaded as a Word .doc file with the desired file name. <%@ Page Language = "VB" %> <script runat = "server" > Public Sub Page_Load(sender as Object, e as EventArgs) 'build Zoom> " & _ "< / w:WordDocument> " & _ "< / xml> " & _ "<![endif]- -> " strBody = strBody + _ "<style> " & _ "<!- - / * Style Definitions " * / @page Section1{size:8.5in 11.0in; " & _ " margin:1.0in 1.25in 1.0in " & _ header-margin:.5in; " & _ " mso-footer-margin:.5in; mso-paper-source:0;} " " & _ "div.Section1{page:Section1;}- -> " & _ "< / style> < / head> " strBody = strBody + _ "<body lang = EN-US style = 'tab-interval:.5in example that utilizes the same technique to implement "Download as Excel" functionality for a web page with content from a data source. I got this from among a bunch of re