Hi all,
I have set readonly property of text box as true. Coz i dont want user to be able to change it's value. It is going to contain date value, which will be inserted into it by an Ajax Calendar control. But when i accept their values in code file, it shows value as blank !! Aftwerwards I changed readonly property false before accepting value in code file, but still the same result.
How is this happening? Plz help
P.s I dont want to use labels

Recommended Answers

All 4 Replies

javaScript Code:

<script language="javascript" type="text/javascript">
        function showDate() {
            var date = document.getElementById('txtDate').value.toString();
            document.getElementById('selectedDate').value = date;

        }
 </script>

page.aspx:

<asp:Button ID="btnGetDate" 
   runat="server" 
   OnClick="btnGetDate_Click" 
   Text="Button" 
   OnClientClick="showDate()"/>

<input id="selectedDate" type="hidden" runat="server" />

code behind:

protected void btnGetDate_Click(object sender, EventArgs e)
        {
            string Date = selectedDate.Value.ToString();
        }

Personally i use the property enabled="False" if i want no body touch that textbox, in the only situation i use read only is when play around with gridview.

regards

It is not the problem of Readonly Propert.

You are changing the value from Javascript which will change the values only in the client side and will not affect the server Value.

That is why you are getting the Original Value. You need to change the Textbox values from server side

I have observed that this problem is specific to Ajax controls. In the txtbox i am accepting value from Ajax Calendar Control. Only there reasd only gives problem. In all other cases everything's fine !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.