How to display current date automatically in ASPxDateEdit Control on default loading - devexpress

I need to display the Current Date (17/Jun/2013) Automatically in the ASPxDateEdit Control by default while loading.
How to implement this?Any default property is there?

Please follow this example and modify according to your requirement:
<dx:ASPxDateEdit runat="server" ID="uniquedateid" Width="95px"><ClientSideEvents Init="function(s,e){ s.SetDate(new Date());}" /> </dx:ASPxDateEdit>

I suggest you to look here. The Date property will solve your problem.

Related

Sharepoint FormField default value?

Is it possible to add default values to a sharepoint FormField object?
Here is my code:
<SharePoint:formfield runat="server" id="ff8{$Pos}" ControlMode="Edit" FieldName="Body" ItemId="{#ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff8',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(#ID)),'#Body')}" />
<SharePoint:fielddescription runat="server" id="ff8description{$Pos}" FieldName="Body" ControlMode="Edit" />
Basically, I want the form field's default value to be more than just the Body parameter (perhaps 2 parameters and some custom text). Is this possible?
(Also, I know you can substitute the SP form Field with an ASP TextBox, but I'm running into problems with that--specifically, the text box doesn't support rich text, and the post-back doesn't preserve line breaks.)
Thanks in advance!
It looks like I was able to solve this. Other forums had me using an ASP Text box and writing code behind in C#, but it's really not necessary if you use a Sharepoint:InputFormTextBox instead.
<SharePoint:InputFormTextBox ID="ff8{$Pos}" RichText="true" text="{concat(#Body, "CustomText", #secondparameter)}" RichTextMode="FullHtml" TextMode="MultiLine" runat="server" __designer:bind="{ddwrt:DataBind('u',concat('ff8',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(#ID)),'#Body')}" Width="99%" Rows="10"/>
If this was an obvious solution, please forgive my ignorance. This is new territory for me.

ASPxDateEdit: How can I show only the date component of a DateTime (ie, hide the time component)?

I am using an ASPxDateEdit control for editing of a date field. The time component of this particular field will never be relevant, so I'd like to hide it so that only the date component is visible. I've tried the following:
<dx:ASPxDateEdit ID="dpExpirationDate" EditFormat="Date" runat="server" />
<dx:ASPxDateEdit ID="dpExpirationDate" EditFormat="Custom" EditFormatString="M/d/yyyy" runat="server" />
<dx:ASPxDateEdit ID="dpExpirationDate" EditFormat="Custom" EditFormatString="{0:M/d/yyyy}" runat="server" />
I am setting it like this:
dpExpirationDate.Value = Entity.ExpirationDate
No matter what I try, it still shows 7/9/2012 12:00:00 AM. How can I hide the time component?
Also, someone with rep may wat to add ASPxDateEdit as a tag.
Update: I found the problem and it's very quirky, but what would one expect from a DevExpress control?
I've found that setting the ASPxDateEdit's Visible property to either True or False in the codebehind will cause it to show the time component regardless what you set for its EditFormat property. Also, pushing in a date string will also result in the same effect, so don't try to assign DateTime.Now.ToString() to its Value property or you will experience the same results.
Your first variant works in my environment. So, set EditFormat attribute value to Date.
EditFormat enumeration values.
As for toggling Visible attribute, I couldn't reproduce this issue. However, there is an important difference between Visible and ClientVisible attributes. If you set Visible to false, control won't be rendered. So, you can't manipulate with it on client side. If you want control to render hidden, you must use ClientVisible attribute.

Why does AjaxControlToolkit TabContainer render all custom control markup properties?

This is a strange one to explain but hope I make sense.
Our organisation has a library of custom controls that we use in our solutions. One example of these controls is a textbox combined with a set of validators which can be configured appropriately by its properties set in the markup.
I now have a problem when using this control in (which I beleive to have narrowed it down) a TabContainer.
If I wanted to use the following markup in the container:
<scc:TextBox ID="txtEmailAddr" runat="server" CssClass="input EmailAddress" EnforceEntry="EmailAddress"
ErrorMessage_RequiredFieldNotCompleted="" ErrorMessage_ShowExclamation="true"
MaxLength="150" ShowErrorMessageBelow="false" Label="Email Address " />
When I save or reload the .aspx markup it then renders the following markup for the same control:
<scc:TextBox ID="txtEmailAddr" runat="server" CssClass="input EmailAddress" EnforceEntry="EmailAddress"
ErrorMessage_RequiredFieldNotCompleted="" ErrorMessage_ShowExclamation="True"
MaxLength="150" ShowErrorMessageBelow="False" Label="Email Address "
ClientSidePreventInvalidChars="True" EnableClientScript="True"
EnfoceOnPaste="False" EnforceMaxLengthWithRXOnMultiline="True"
EnforceOnPaste="False" EnforceSpaceInPostcode="True"
ErrorMessage_InvalidFormat="Email Address : Please enter a valid email address"
ErrorMessage_NumericValueInvalidOrOutOfRange="Email Address requires a number to be entered in the range to ."
GuidanceText="" GuidanceText_RenderInMouseoverPanel="False"
JavascriptURL="~/Include/TextBoxMaximumLength.js" LabelBold="False"
LabelCSSClass="" MaxValue="9999999" MinValue="-9999999" Read_Only="False"
RememberAnswer="False" RenderInParagraphs="True"
RenderRequiredTextForRequiredFields="True" Required="True"
RequiredField_InitialValue="" Rows="0" ShowMaxLength="False" Text=""
TextBox_TabIndex="0" TextboxSkinID="" TextMode="SingleLine"
TooltipPopup_BodyText="" TooltipPopup_TooltipText="(guidance)"
ValidationGroup="" ValidationExpression="" />
This would not be a problem other than the properties that are now being rendered in the markup are overriding default functionality of the actual control. In this case the default Email Address regular expression is being ignored because the property 'ValidationExpression' is being set to an empty string!
Again I could place the default regex in that property, but I would just like to understand why the markup is behaving in this manner?
Thanks.
Get the code for the AjaxContolToolkit and step through it to see why all properties are rendered. You can adjust that code as you need and compile the dll and use that. From personal experience, that is the only way I have found use for the Toolkit because of behaviors like you describe.

ASP.net over ride client ID for form elements

Given a textbox:
<asp:Textbox runat="server" id="txtAddress1" />
This renders as something similar to:
<input name="ctl00$mainContent$txtAddress1" type="text" id="ctl00_mainContent_txtAddress1" />
I don't think browsers autocomplete features recognise this name/ID as a field they can autofill, they are not standard recognised names.
Is there any way to overide the client ID's so that autocomplete has a better chance of recognising them?
2 Points with this.
1) The "Override the Name" feature was introduced in ASP.Net 4.0, where for any property you can choose a hardcoded name instead of the dynamic name. You need to be careful on this as you don't want 2 objects sharing a name.
2) ASP.Net 2.0 and above (may have been in v1.0) has a property on the control called "AutoCompleteType" which provides a hint to the browser on what sort of information is required in the box.
Assuming you're using Asp.net 4.0, and you're aware of the points mentioned by DJIDave, you can use the ClientIDMode property on a control, and set it to 'Static'. Then, what ever you specify in the Id field in Asp.Net will be brought through to your final markup, and will not be 'mangled' (for want of a better word) by Asp.Net.

AJAX Calendar extender on modalpopup returns null

I'm having some trouble getting a datetime from calextender on a modalpopup I have.
<asp:TextBox ID="txtPopEndDate" runat="server" Enabled="false"></asp:TextBox>
<img id="calButton" alt="" title="Show Calendar" src="~/App_Themes/Main/img/calendar.png"
runat="server" height="20" style="cursor: hand;" />
<ajax:CalendarExtender Animated="true" TargetControlID="txtPopEndDate"
runat="server" PopupButtonID="calButton"
Enabled="true" ID="calExtender" Format="dd/MM/yyyy"/>
are the controls I have to select the date, now when I press the ok button I handle the data including the date. However, if I try to fetch the date using calExtender.selectedDate property I get nothing. the same goes for manually getting the string from the textbox and parsin that.
I have to mention that the other data from textboxes and dropdowns on that popup work without a glitch. any help here would be greatly appreciated.
Your textbox has enabled = false. I think this spits out a disabled attribute set to true in the html, therefore the post of the form would not send the value. Why dont you want the textbox enabled?
Im also assuming your trying to grab the value after a postback ? Is that true?
yep,
in the meanwhile I found a solution to the problem. as you said, the textbox apparently needs to be enabled. this means the option for erroneous dates.
I got the value from the textbox and parsed it that way with a DateTime.TryParse to secure a correct date.
if anyone has a better option, let me know
We used Enabled="false" on TextBoxes linked to the CalendarExtender all through our application without a problem. Then I added a date picker to a page which refused to co-operate. The TextBox value was never available on PostBack.
I found the solution here:
http://www.west-wind.com/weblog/posts/2005/Dec/20/ASPNET-20-ReadOnly-behavior-change-when-EnableViewState-is-false
What I found was:
I could set ReadOnly = true, then retrieve the value from the Request on PostBack with TextBox1.text = Request[TextBox1.UniqueID].
I could use TextBox1.Attribute.Add("readonly", "readonly"), then the Text property was set as I expected.
I could not retrieve the value with Enabled = false; or TextBox1.Attribute.Add("disabled", "disabled")
We didn't have ViewState disabled on this page and we didn't get this behaviour on other pages, so I guess this behaviour can be triggered by something else too.

Resources