CalendarXP.net Support Forum Index CalendarXP.net Support
Most forums here are private and invisible to public.
 
 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to prevent the user from editing the date field directly?

 
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q.
View previous topic :: View next topic  
Author Message
calendarxp
Site Admin


Joined: 30 Jan 2005
Posts: 409

PostPosted: Tue Feb 15, 2005 6:58 pm    Post subject: How to prevent the user from editing the date field directly? Reply with quote

Just set your <input> tag as following:
Code:
<input name="dateFieldxxx" value="" readonly="true" onfocus="this.blur()" >


Note:

For the new ASP.NET 2.0, there is a subtle change to its readonly behavior when EnableViewState is set to false on the Page - the ReadOnly value will no longer post back in ASP.NET 2.0 - the value gets lost. e.g.
Code:
<%@ Page language="c#" enableviewstate="false" Trace="true" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.Textbox1.Text = "readonly text";
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        this.lblMessage.Text = this.Textbox1.Text;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>
<form runat="server" id="Form1">
<asp:textbox ID="Textbox1" runat="server" ReadOnly="true" ForeColor="silver"></asp:textbox>
<asp:textbox ID="Textbox2" runat="server" ReadOnly="true">Some Text</asp:textbox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
<asp:Label ID="lblMessage" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>

This difference between ASP.NET 1.1 and 2.0 can be worked around by using
Code:
this.TextBox1.Text = Request[this.TextBox1.UniqueID];
in the Page_Load().

Details can be found here: http://west-wind.com/weblog/posts/3939.aspx

_________________
Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CalendarXP.net Support Forum Index -> CalendarXP F.A.Q. All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Copyright 2003- Idemfactor Solutions, Inc. All rights reserved.
Powered by phpBB © 2001, 2005 phpBB Group