Way to automatically update date and time by clicking a button?

J

Josh

I know if you have a date and time field, when you first open the form, the
date and time defaults to that date and time. Is there a way to add a button
so if i click the button it will automatically update the date and time to
when I clicked the button? Thanks!
 
R

Rajitha

Hi,
Take a text field and in button onclick event write below code.
XPathNavigator xn = MainDataSource.CreateNavigator();
xn.SelectSingleNode("/my:myFields/my:field1",
this.NamespaceManager).SetValue(DateTime.Now.ToString());
Here field1 is the text field.
Hope this helps.
 
S

SMS

I know if you have a date and time field, when you first open the form, the
date and time defaults to that date and time. Is there a way to add a button
so if i click the button it will automatically update the date and time to
when I clicked the button?  Thanks!

You can also put rules in the button and do it without coding
 
S

Swathi (GGK Tech)

Hi,
You can do this suing the rules on a button. Follow the below steps.
1.Add a date time field to the form.
2.Add a button.
3.Go to button properties. Click Rules button.
4.Click Add, and then click Add action.
5.Select ‘Set a field value’ in ‘Action’ drop down, Select the date time
field in Field.
6.Click fx beside the Value box. Then click Insert function, select now().
7.Click ok until all the windows gets close.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top