Hello,
I have a custom control that displays the date and time. I currently
have properties for the day, month, year, hour and minute, which have to
be set separately. This is inefficient.
I would like to have one property that I can use to pass in a DateTime,
and have the control pull out the various bits from that. I tried ...
public DateTime DateTimeDT {
get {
return new DateTime(m_Year , m_Month, m_Day, m_Hour, m_Minute, 0);
}
set {
m_Year = value.Year;
m_Month = value.Month;
m_Day = value.Day;
m_Hour = value.Hour;
m_Minute = value.Minute;
}
}
but when I try and use this in code ...
DateTimeDT="<%= DateTime.Now()% >"
I get the error "<%=DateTime.No w()%> is not a valid value for DateTime".
Please could someone enlighten me as to a) what I'm doing wrong and b)
the correct/best/easiest way to do this? TIA
--
Alan Silver
(anything added below this line is nothing to do with me) 8 1869
Try this:
public DateTime DateTimeDT {
get {
return m_dtDateTime;
}
set {
m_dtDateTime = value;
}
}
where m_dtDateTime is a private or protected instance variable of type
DateTime.
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:t4******** ******@nospamth ankyou.spam... Hello,
I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient.
I would like to have one property that I can use to pass in a DateTime, and have the control pull out the various bits from that. I tried ...
public DateTime DateTimeDT { get { return new DateTime(m_Year , m_Month, m_Day, m_Hour, m_Minute, 0); } set { m_Year = value.Year; m_Month = value.Month; m_Day = value.Day; m_Hour = value.Hour; m_Minute = value.Minute; } }
but when I try and use this in code ...
DateTimeDT="<%= DateTime.Now()% >"
I get the error "<%=DateTime.No w()%> is not a valid value for DateTime".
Please could someone enlighten me as to a) what I'm doing wrong and b) the correct/best/easiest way to do this? TIA
-- Alan Silver (anything added below this line is nothing to do with me)
Jon,
Thanks for the reply, but either I didn't make myself clear or you
misread the question ;-)
I have the property set/get code working fine, my problem is how to use
this in the calling page. I would like to be able to do something like
....
<MyControls:Dat eTimePicker ID="dtpDTP" DateTimeDT="<%= DateTime.Now()% >"
Runat="Server" />
but this gives the error "<%=DateTime.No w()%> is not a valid value for
DateTime". I tried adding ToString() on to that as well, but that gave
the same error.
Your code did the same. I think the problem is in the way I'm passing
the value to the control. I can set the property fine in code ...
dtpDTP.DateTime DT = dateTime.Now;
I just can't set it in the tag.
Any ideas? Thanks again. Try this:
public DateTime DateTimeDT { get { return m_dtDateTime; } set { m_dtDateTime = value; } }
where m_dtDateTime is a private or protected instance variable of type DateTime.
"Alan Silver" <al*********@no spam.thanx> wrote in message news:t4******* *******@nospamt hankyou.spam... Hello,
I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient.
I would like to have one property that I can use to pass in a DateTime, and have the control pull out the various bits from that. I tried ...
public DateTime DateTimeDT { get { return new DateTime(m_Year , m_Month, m_Day, m_Hour, m_Minute, 0); } set { m_Year = value.Year; m_Month = value.Month; m_Day = value.Day; m_Hour = value.Hour; m_Minute = value.Minute; } }
but when I try and use this in code ...
DateTimeDT="<%= DateTime.Now()% >"
I get the error "<%=DateTime.No w()%> is not a valid value for DateTime".
Please could someone enlighten me as to a) what I'm doing wrong and b) the correct/best/easiest way to do this? TIA
-- Alan Silver (anything added below this line is nothing to do with me)
--
Alan Silver
(anything added below this line is nothing to do with me)
OIC
Well, you're effectively initializing DateTimeDT with DateTime.Now (), so
why not do that in the code rather than in the tag? Are you always going to
be using DateTime.Now ()?
- Jon
"Alan Silver" <al*********@no spam.thanx> wrote in message
news:JW******** ******@nospamth ankyou.spam... Jon,
Thanks for the reply, but either I didn't make myself clear or you misread the question ;-)
I have the property set/get code working fine, my problem is how to use this in the calling page. I would like to be able to do something like ...
<MyControls:Dat eTimePicker ID="dtpDTP" DateTimeDT="<%= DateTime.Now()% >" Runat="Server" />
but this gives the error "<%=DateTime.No w()%> is not a valid value for DateTime". I tried adding ToString() on to that as well, but that gave the same error.
Your code did the same. I think the problem is in the way I'm passing the value to the control. I can set the property fine in code ...
dtpDTP.DateTime DT = dateTime.Now;
I just can't set it in the tag.
Any ideas? Thanks again.
Try this:
public DateTime DateTimeDT { get { return m_dtDateTime; } set { m_dtDateTime = value; } }
where m_dtDateTime is a private or protected instance variable of type DateTime.
"Alan Silver" <al*********@no spam.thanx> wrote in message news:t4****** ********@nospam thankyou.spam.. . Hello,
I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient.
I would like to have one property that I can use to pass in a DateTime, and have the control pull out the various bits from that. I tried ...
public DateTime DateTimeDT { get { return new DateTime(m_Year , m_Month, m_Day, m_Hour, m_Minute, 0); } set { m_Year = value.Year; m_Month = value.Month; m_Day = value.Day; m_Hour = value.Hour; m_Minute = value.Minute; } }
but when I try and use this in code ...
DateTimeDT="<%= DateTime.Now()% >"
I get the error "<%=DateTime.No w()%> is not a valid value for DateTime".
Please could someone enlighten me as to a) what I'm doing wrong and b) the correct/best/easiest way to do this? TIA
-- Alan Silver (anything added below this line is nothing to do with me)
-- Alan Silver (anything added below this line is nothing to do with me)
<%= is equal to Response.Write. So you're essentially doing a
Response.Write( DateTime.Now()) with that code.
I suggest you set the DateTimeDT property within your codebehind
instead, or you could use databinding syntax, and databind your control.
>Well, you're effectively initializing DateTimeDT with DateTime.Now (), so why not do that in the code rather than in the tag? Are you always going to be using DateTime.Now ()?
No, that was just an example for simplicity. Usually the datetime would
be set to a value from a database.
"Alan Silver" <al*********@no spam.thanx> wrote in message news:JW******* *******@nospamt hankyou.spam... Jon,
Thanks for the reply, but either I didn't make myself clear or you misread the question ;-)
I have the property set/get code working fine, my problem is how to use this in the calling page. I would like to be able to do something like ...
<MyControls:Dat eTimePicker ID="dtpDTP" DateTimeDT="<%= DateTime.Now()% >" Runat="Server" />
but this gives the error "<%=DateTime.No w()%> is not a valid value for DateTime". I tried adding ToString() on to that as well, but that gave the same error.
Your code did the same. I think the problem is in the way I'm passing the value to the control. I can set the property fine in code ...
dtpDTP.DateTime DT = dateTime.Now;
I just can't set it in the tag.
Any ideas? Thanks again.
Try this:
public DateTime DateTimeDT { get { return m_dtDateTime; } set { m_dtDateTime = value; } }
where m_dtDateTime is a private or protected instance variable of type DateTime.
"Alan Silver" <al*********@no spam.thanx> wrote in message news:t4***** *********@nospa mthankyou.spam. .. Hello,
I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient.
I would like to have one property that I can use to pass in a DateTime, and have the control pull out the various bits from that. I tried ...
public DateTime DateTimeDT { get { return new DateTime(m_Year , m_Month, m_Day, m_Hour, m_Minute, 0); } set { m_Year = value.Year; m_Month = value.Month; m_Day = value.Day; m_Hour = value.Hour; m_Minute = value.Minute; } }
but when I try and use this in code ...
DateTimeDT="<%= DateTime.Now()% >"
I get the error "<%=DateTime.No w()%> is not a valid value for DateTime".
Please could someone enlighten me as to a) what I'm doing wrong and b) the correct/best/easiest way to do this? TIA
-- Alan Silver (anything added below this line is nothing to do with me)
-- Alan Silver (anything added below this line is nothing to do with me)
--
Alan Silver
(anything added below this line is nothing to do with me)
><%= is equal to Response.Write. So you're essentially doing a Response.Write (DateTime.Now() ) with that code.
I suggest you set the DateTimeDT property within your codebehind instead, or you could use databinding syntax, and databind your control.
One of the main things I want to be able to do with this is use
databinding. Say I have this control in a DataList Itemtemplate, I want
to be able to pass in a datetime value from the data source.
That's really where my question lies. The fact of being able to set the
datetime in the tag was more a simple example of the problem. If you
could show me how to do this with data binding, I would be very
grateful.
Thanks for the reply.
--
Alan Silver
(anything added below this line is nothing to do with me)
....
<ItemTemplate >
My date: <%# DateTime.Now %> .. and a property from the data source:
<%# ((DataRowView)C ontainer.DataIt em)["SomeDate"] %>
</ItemTemplate>
Container.DataI tem is of the type object, which represents ONE item in
the data source. You can cast it to its real type and access its
properties/etc.
><ItemTemplat e> My date: <%# DateTime.Now %> .. and a property from the data source: <%# ((DataRowView)C ontainer.DataIt em)["SomeDate"] %> </ItemTemplate>
Container.Data Item is of the type object, which represents ONE item in the data source. You can cast it to its real type and access its properties/etc.
I tried casting it directly to DateTime, but that didn't work. You seem
to be casting the DataItem to a DataRowView and passing that in. Don't
you need to cast that to a DateTime first?
I actually found a way around it by creating a small utility function
....
DateTime MakeDT(object objDt) {
return (DateTime)objDt ;
}
which did the trick. I then did the data binding like this ...
<%# MakeDT(DataBind er.Eval(Contain er.DataItem, "Eventdate" ))%>
Obviously this is for internal use only, and would only be used when I
knew the object being passed in contained a valid DateTime, that's why I
didn't use any error checking. Your way is certainly neater as it avoids
the auxiliary function.
Thanks for the reply.
--
Alan Silver
(anything added below this line is nothing to do with me) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Todd Schinell |
last post by:
Back in July, Jeffery Tan posted this:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OWOTdf0VDHA.2296%40cpmsftngxa06.phx.gbl
In response as to how to get click events from a user control to
invoke a method in the parent form.
This code doesn't seem to work for me, I've tried it a number of times
with very simple test cases (A user control with a single button and a
parent form with a single text box) and it always...
|
by: Fritz Switzer |
last post by:
I'd like to have a string assigned the value of a
DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM"
format.
For example:
DateTime.Now.AddMinutes(30) returns "00:30"
DateTime.Now.AddMinutes(90) returns "1:30" or "01:30"
|
by: klynn |
last post by:
I'm wondering what the best way to do the following:
I have a page with a table. I built a custom class that creates a
System.Web.UI.WebControls table object and return it to the webpage as a
property. But its not reading the table correctly. It doesnt see the
tablerows and tablecell objects.
First, I'm not sure why its not reading the table properly?
Second, I wonder if there's a better way to do this? Maybe a custom control?
I haven't...
|
by: Glenn |
last post by:
Hello
Is it possible to pass arguements to a .net service once it is in a
running state.
If this is not possible , are they alternative ways in which to achive
the same thing?
Glenn
|
by: Jon Vaughan |
last post by:
Hi,
I was looking for a control that you enter time values into , I started off
with a textbox, but then saw the datetime picker had a custom format for
Time , so I entered HH:mm. The conctrol does show time in the box , but in
HH:mm:ss, I would like to drop the ss, also I dont want the user to beable
to click the dropdown to select the date. Im looking purely for a time
entry.
Is this the right control and if not is there a better...
| |
by: Ryan |
last post by:
My form includes a field of the DateTime type. I want to allow the user to
be able to set both the date and the time. By default the DateTimePicker
shows just the date and calendar, the time is autoset to 12:00 PM. How's
the best way to do this?
I tried creating a custom format which displays both the date and time and
turned on the Up Down option (DateTimePicker.ShowUpDown). This works but is
a bit clunky. The user has to click on...
|
by: cpnet |
last post by:
I'm able to pass string parameters with no problems to a LocalReport being
displayed by the ASP.NET ReportViewer control. However, my report also has
a DateTime parameter. LocalReport.SetParameters(..) only seems to allow me
to set string parameters. Is there a way to pass DateTime (or other types)
of parameters? Or can I only use string parameters in a LocalReport if I
need to pass them in from my ASP.NET app?
Thanks,
cpnet
|
by: gregcm |
last post by:
I've got a custom control that is trying to allow the user to enter a
DateTime in a definable format and I was wondering if there was an
easy way to alter the look of said control based on the contents of
the format string. For example I would like a year TextBox that is
small if input formatting string contains "yy" and larger if it
contains "yyyy".
I guess I could write a parser with string.Contains et. al. but that
seems fairly kludgy,...
|
by: indika |
last post by:
Hi,
I'm a newbie to python but have some experience in programming.
I came across this requirement of using datetime.date objects
associated with some another object.
eg. a dictionary containing datetime.date =string
{
datetime.date(2001, 12, 3): 'c',
datetime.date(2001, 12, 1): 'a',
datetime.date(2001, 12, 2): 'b'
}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |