Change url text dynamically from text file
I need to use a text file created from a form to rewrite the
links on my main page. Can I put some kind of javascript in the
href so when the page loads it'll rewrite the link to point to
"newpic1.jpg" where newpic1.jpg is one of the items from the text
file created by my form?
Please help, this has got me really stuck. All help greatly
appreciated!!!
ff
flashfloozie wrote:
> how would I identify what line of the text file each
link will use?
>
> btw I really appreciate you taking time to help me with
this!!!
>
> ff
that is the difficulty with a text file...
if the links are to remain only for a session, you can set a
session var
a simplified method - using PHP - would be:
1. form
<form id="form1" name="form1" method="post"
action="process_form.php">
<label for="selectimg">Select Image:</label>
<select name="selectimg1" id="selectimg">
<option value="img_blue.gif">Image blue</option>
<option value="img_red.gif">image red</option>
</select>
</form>
2. process_form.php
<?php
$_SESSION['img_array']['img1']=$_POST['selectimg1'];
?>
3. wherever the image needs to be displayed:
<img src="/images/<?php echo
$_SESSION['img_array']['img1']; ?>" />
Please be advised that this is a very simplified version and
that if you
do use something like this you have to first clean up
whatever the form
submits. NEVER trust user input - it could be malicious
code...
Anurag
Similar Messages
-
Currency changes rates through TBEX from excel file getting erro
Hi,
When i am trying to upload the currency changes rates through TBEX from excel file getting error message:
Error "The macro 'ThisWorkbook.TableBackToR3' cannot be f" occurred during macro execution
Kindly guide what macro i need to define in excel sheet. or should i need to activate something in excel sheet relates to macros.
Regards,
Salil...When you call it the first time, it new Shell() constructs a new Display for you (the default).
The second time, it gets the default display, but you are in a different Thread now. Since you have to create your widgets in the UI thread, it gives you that error.
To run code in the UI thread, Display provides two methods:
display.syncexec(..)and
display.asyncexec(...)see
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/swt_threading.htm
for more details. -
How do I get Adobe Air Desktop App to notify user that a URL text file has been updated?
How do I get an Adobe Air Desktop App to notify user that a URLRequest ".txt" file has been updated? via blinking system tray icon or something.
New to Air and need someone to point me in the right direction. I have been searching web for hours and probably not asking the question right.
I have a very simple Desktop App that just loads a text file from a web location into a dynamic text field at a set timer. it just repeats this action on the timer. right now every 5 minutes
What would the actionscript be to tell the Air App to look at the date or time stamp of the ".txt" file and notify user if its new?
ThanksTry to follow below steps
Click on Finder and then hold Command + Shift + G keys on your keypad
It will open Go to folder window, type exactly ~/Library and click on Go
Then open Application Support > Adobe folders
Trash AAMUpdater and OOBE folders.
Now click on finder and hold Command + Shift + G keys on your keypad.
This time type /Library and click on Go.
Make sure to remove ~ symbol.
Then open Application Support > Adobe folders.
Trash AAMUpdater, Adobe Application manager, OOBE folders.
Now Click on Finder and then hold Command + Shift + U keys on your keypad.
It will open utilities folder.
Trash Adobe Creative Cloud and Adobe Application Manager folders
Download and Run CC cleaner tool from below link
http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems/_jcr_conte nt/main-pars/accordion_container_1/accordion-par/accordion-item-1/accordion-item-par/proc e dure/proc_par/step_3/step_par/download/file.res/AdobeCreativeCloudCleanerTool.zip
Accept the license agreement and click on Adobe Application Manager
Then click on clean up selected
Close the window
Download and install Creative Cloud App from below link
Free Creative Cloud | Download Adobe Creative Cloud free trial -
Make changes in text file.
Hi all,
we are uplaoding a text file by bdc but when we are importing our text file from some other system we are getting some box type symbol in that text file , how to delete those boxes before uploading it to sap
plz help
regards
sarabjitHi,
That is aspecial character you need to remove this special character before you pass this data to BDC....
data: lv_char type x value '0D'.
do.
if view_fields-value cs lv_char.
replace lv_char with space into view_fields-value.
condense view_fields-value.
modify view_fields index lv_index transporting value.
else.
exit.
endif.
enddo.
here you might have to replace 0D with the correct value whihc you can see in dbug mode by clicking on the hex display button also try with '09 in place of 0D.
Regards,
Himanshu -
I have a text file named Log.txt. I want that as soon as something is written on log.txt a notification is generated instantly. I don't want to use two threads: one that writes and other that reads and generates notification instead I want to use some kind of event generator such that as soon something is written an event is generated in which I will add send notification in the action part. Please guide me its urgent
Hi.
I'm afraid I do not know of any possibility other than periodically polling for changes. As far as I know, e.g. log4j also solves its reconfiguration using a thread checking the last modified timestamp on its configuration file.
Sorry. -
Editing and changing large text file
hi,
new to this, so bare with me.
got a large text file 44meg and i need to change some values in it.
example:
TSX ;20030102;40302216;40300579;1980;1900;3762000
i need to change the lines so that they read:
TSX ;20030102;302216;300579;1980;1900;3762000
thus removing the leading 40 in the middle cols.
Thanks in advance
johncrap, small mistake
1) use BufferedReader to read in the file line by line (BufferedReader.readLine())
2a) for each line, split it on the semicolons (String.split())
2b) change the middle value using String.substring()
2c) construct a new line by appending all strings in the array returned by 2a) to eachother
2d) write this new line to a file using PrintStream (PrintSteam.println())
3) when done, close both the reader and the printstream. -
Reading data from dynamically from different file.
Is there any function moudle or class to read data from a file in application layer, whoes structure is changing dynamically.
Urgent....... Can any one help me out in this......
Thanks in advance....
Thanks,
feroz.Hi Feroz,
Do u mean that structure of the file on the application server is changing dynamically.
The following is the FM to read data from a file on Application Server.
OPEN DATASET FNAME FOR INPUT in text mode encoding default.
LOOP AT TAB INTO WA.
READ DATASET FNAME INTO WA.
IF SY-SUBRC 0.
EXIT.
ENDIF.
WRITE: / WA-COLUMN1, WA-COLUMN2.
ENDLOOP.
This is the FM to search the file on Application Server.
F4_DXFILENAME_TOPRECURSION
Regards,
Sai
Edited by: Sai Krishna Kowluri on Jul 15, 2008 9:45 AM -
How to change destination table dynamically in configuration file in ssis?
hello,
i have a package i am having one data flow task.in data flow task i have one source and one destination.source and destination are different.i have created xml configuration file by configuring source and destination connection
strings.
now i want to change destination in the same server to different database with out opening the package.i want to directly change in the config file.we can change it by modifying configured value proerty and intial catalogue value.but if the table is not
existed in the changed database.how we can create it dynamically.HI jiri Neoral,
thanks for reply,as you said above process by this we can do change only databasename.if in my destination database,the table which i used in package is not existed,can we create it dynamically
using config file.later changing table name is possible?
For that you need to have a step in SSIS package prior to data flow task to check if table exists and if not create it
You can use execute sql task with query like below
IF OBJECT_ID('TableName') IS NULL
CREATE TABLE TableName
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Change Html Title dynamic from Flash
Hi,
I want to change the Title of the Html page dynamically from
the embedded Flash.
The Title, that appears on Browser bars etc.
Could I do this?
On init I can load the Html source code in with LoadVars, and
onData (src) change the Title with subString method, but, how then
could I pass the new value back to the Html page, so the Browser
Title changes?
Thank you.
LuciewongThank you both GWD and Dave for the help.
I know your code works under normal circumstances, just in my
case, I can't get it to work.
Because, on a subsequent Frame, called after the
ExternalInterface.call,
I have a getURL(javascript) to change the doc. background
color.
Now, either the Title changes or the background color
changes, but both after each other, can't make it.
I have tried Ext,CallBack function, so when the Title changes
and callBack is true, move on, but still then it changes the BG,
but not the title anymore.
I must do something wrong with the callBack function?
Thank you for your help.
Regards,
Luciewong -
Pagination changes when creating PDF from FM file
Using Structured FM 7.2p158, Adobe Acrobat Professional 8.1.3. I have updated a chapter with a graphic and want to send a specific page to a colleague. Tried to print the individual page to a file, then distill that print file to a PDF file; Distiller flushed it, whether I used the Acrobat PDF printer or my regular printer.
Next tried printing the entire chapter, which works, but the PDF pagination is changed from the original FM file. Tried setting to "Standard" and "High Quality Print" but still get the same result.
Any suggestions, please?
Thanks,
CherylCheryl Dwyer wrote:
Tried to print the individual page to a file, then distill that print file to a PDF file; Distiller flushed it, whether I used the Acrobat PDF printer or my regular printer.
Cheryl,
You should only be using the AdobePDF printer instance when working on FM files. If you changed to a different printer and created output using that to send to Distiller, then there can be a number of issues, especially if you've somehow used the printer fonts (you may have substituion enabled in the printer driver giving you different metrics). The SetPrint utility from Sundorne <http://www.sundorne.com/FrameMaker/Freeware/setPrint.htm> will ensure that your default printer in FM is always the AdobePDF. Note: you can still manually switch in FM if you need to directly output hardcopy to your system printer.
If Distiller "flushed" your output, then there should have been a log file generated that specifies what the error was. This might help provide some solution to your original problem.
The joboptions settings in Distiller wouldn't be creating the reflows that you're seeing. It's probably one of the fonts, printer instance, graphic size (dimension/scale) that caused your problem. -
Loading a text file into a global variable issue - really a global var?
From all the documentation and examples I can find, it appears that it would be
correct to create a global array variable [outside of any functions] to load image names into,
then use these images for a slideshow. I want to make the app dynamic, in that changing the text file gives a new set of images.
The global variable goes null [no values] after the load event listener. Why is that?
Isn't global, well global, and alive for the duration of the SWF?
PARAMS.TXT:
monthNames=January,February,March,April,May,June,July,August,September,October,November,De cember&dayNames=Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
CODE:
var dNames:Array = new Array();
var mNames:Array = new Array();
var request:URLRequest = new URLRequest("images/params.txt");
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try
variables.load(request);
catch (error:Error)
trace("Unable to load URL: " + error);
trace("2 mNames 2: " + mNames[2]);
trace("2 dNames 3: " + dNames[3]);
stop();
function completeHandler(event:Event):void
var loader:URLLoader = URLLoader(event.target);
dNames = loader.data.dayNames.split(",");
mNames = loader.data.monthNames.split(",");
trace(loader.data.dayNames);
trace("1 mNames 2: " + mNames[2]);
trace("1 dNames 3: " + dNames[3]);
OUTPUT:
2 mNames 2: undefined
2 dNames 3: undefined
Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
1 mNames 2: March
1 dNames 3: Wednesday
How do I access these values after loading from the external file, after the load?
Thanks in advance.The statement you quoted from whatever Adobe documentation is correct.
If you want to load the data into the arrays before anything else happens, then have anything else that happens execute via the completeHandler function... after the data is loaded and processed into the arrays.
the command: loadFile() executes before the trace("2:" +images[4]); command. The loadFile function is processed and the loading process BEGINS... but starting the loading does not delay the main processing from continuing down the line--the loading itself becomes a secondary/background task. The command was to execute the loadFile function and the processing of that function was completed. If you don't believe so, then add a trace...
function loadFile():void
vars.dataFormat = URLLoaderDataFormat.VARIABLES;
vars.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
vars.load(new URLRequest("images/fnames.txt"));
trace("started loading");
If you add that trace, you should see that the loadFile function execution is completed and the next line in your code is then processed... trace(2....)
The addEventlistener does not stop anything. The addEventListener code is assigning a monitor, not a traffic controller... it is telling the monitor to indicate when the data has finished loading. It is not telling anything to stop program execution.
So if you want to wait until the data is loaded before you do anything else... it goes....
function onComplete(evt:Event):void
var urlVars:URLVariables = evt.target.data;
images = vars.data.images.split(",");
tnails = vars.data.thumbnails.split(",");
................HERE................. -
How can i change a text on the frontpanel?
Hello,
i have a cluster which looks like the attached cluster but with more and smaller quadrants.
Now i want to add a text above each column. This can be done with a description. But now i want to load the description dynamically from somewhere (file, global) so that it must be changeable. But it seems not to be possible to change the text of a decoration.
What other possibilities are there to add a text above the cluster? I tried to to it with a text-array but there i cant make the text be shown like in the description (counterclockwise).
Thx for any ideas.
Attachments:
text.vi 10 KBHi OnlyOne,
you can get acces to them using the property node, but you can´t change the value. You can use boolean controls to do it.
Mike
Attachments:
text_LV80.vi 16 KB -
Dynamically load content into a "template" swf from text file
I have a dream....
Well, I have a concept. I have not actively pursued Flash in
several years, though I've continued to have it in my arsenal. I've
not done much in the action scripting realm for a while though.
I am trying to create a template that will be used for about
100 different product pages.
It would have two tabs, basically, 2 different graphical
button sets. One will have up to 4 links to similar products, each
tab will be on the side of a square, and I need the ability to not
display a tab if there is no actual link.
As for the other tab, Its a menu that consists of a series of
lines. This can be an external menu, I just need a way to have
flash load the right menu. This menu, when you mouse over a line,
the name of the product appears, as well as a product image that
gets loaded with the menu. The product images would be external,
allowing me to simply replace an image if a new higher end version
of the product comes out.
So, I am totally not an actionscripter. Looks like I need to
load variables from an external file. Can I set a property in the
flash code on the html that tells the movie what dataset to grab
from?
Here's basically what I am looking for
property: value
(load variables for:)
item: 44
(menu1)
faster: 54b.html
slower: 34d.html
left: 43d.html
right: 45c.html
(menu2)
menu:graph5.swf
(menu loads images from external source)
link51: 51d.html
link52: 52c.html
link53: 53c.html
link54: 54d.html
link55: 55b.html
link56: 56d.html
A possible third menu would be text driven, and would use
html to link to various items.
This is a static site, so urls will be fixed.
Is it best to build a php page that serves up data for a
single item, or do one big text file with all 100 or so items? Is
that even possible?
My Flash since MX is very rusty. I am using Flash Pro8. I
would love to create a single file so modifications are to the text
files, unless a new item is released, then it's updating a single
flash menu and updating the text file.
Been spending way too much time in InDesign lately! I used to
be pretty good at Flash!well sorry there fanmap - but I don't think you're going to
be able to get this to work. here's why: the link points to a php
file - which gathers dynamic info from a DB - the return from the
php is generating a string that is based on the DOM and
'constructs' a javascript method that in turn writes to the html
document. although we can embed html into a textField in Flash
there are a limited number of supported html tags - and JS methods
will not operate internally. in addition, (i'm not certain someone
correct this if i'm off) there's no way to 'change' the output of
the php call, therefore you will not be able to read the return
because it is designed to use the DOM and write solely to the
current document. Even if you were to access the JS method from the
swf file (which one can) it will still only write the content of
the php return to the html document - and the output is not
compatible with the textField class. -
Composite control - change text property of textbox from .cs file
Hi All,
I have created a composite control with dropdowns and hiddenfield for datepicker. Now when I change the value of dropdown from browser - client side then its value is retained on postback. But when I change value programmatically its not reflected on
screen.
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
namespace GOV.Framework.Portal.Controls
/// <summary>
/// Simple DateTimePicker control that uses jQuery UI DatePicker to pop up
/// a date, time or both picker.
/// </summary>
[ToolboxBitmap(typeof(System.Web.UI.WebControls.Calendar)), DefaultProperty("SelectedValue"),
ToolboxData("<{0}:DateTimePicker runat=\"server\"></{0}:DateTimePicker>"), PersistenceMode(PersistenceMode.InnerProperty)]
public class DateTimePicker : WebControl
#region "Global Variables"
public enum DisplayControls
TextBox,
Dropdown
public enum DisplayModes
Button,
ImageButton,
AutoPopup,
Inline,
public enum DisplayTypes
Time,
Date,
DateTime
public enum DisplayMonthTypes
Full,
Short
private enum DisplayYearTypes
Full,
Short
private DropDownList ddlDay = new DropDownList();
private DropDownList ddlMonth = new DropDownList();
private DropDownList ddlYear = new DropDownList();
private TextBox txtDate = new TextBox();
private Label lblMsg = new Label();
private System.Web.UI.WebControls.Image imgCal = new System.Web.UI.WebControls.Image();
private HiddenField hdnDate = new HiddenField();
private DisplayModes _DisplayMode = DisplayModes.ImageButton;
private DisplayControls _DisplayControl = DisplayControls.TextBox;
private DisplayTypes _DisplayType = DisplayTypes.DateTime;
private int _StepMinutes = 1;
private int _StepHours = 1;
private DateTime? _MinDate = null;
private DateTime? _MaxDate = null;
private string _OnClientSelect = "";
private string _ButtonImage = "../Images/calendar.png";
private string _CalendarCss = "WebResource";
private string _CalendarJs = "../scripts/timepicker.js";
private DisplayMonthTypes _DisplayMonthType = DisplayMonthTypes.Full;
private DisplayYearTypes _DisplayYearType = DisplayYearTypes.Full;
private int _minYear = DateTime.Now.Year - 25;
private int _maxYear = DateTime.Now.Year;
private int _minMonth = 1;
private int _maxMonth = 31;
private int _minDay = 1;
private int _maxDay = 28;
private string _dateControlClientId = string.Empty;
DateTime? _SelectedDate = null;
private bool _DisplayMessageLabel = true;
private short _tabIndex;
private const string vwst_SelectedDate = "_SelectedDate";
#region "ErrorMessages"
private const string SelectedDate_GreaterThan_MaxDate = "SelectedDate can not be greater than MaxDate";
private const string MaxDate_LessThan_SelectedDate = "MaxDate can not be less than SelectedDate";
private const string SelectedDate_LessThan_MinDate = "SelectedDate can not be less than MinDate";
private const string MinDate_GreaterThan_SelectedDate = "MinDate can not be greater than SelectedDate";
#endregion
#endregion
#region "Properties"
#region "Private Properties"
[Description("Determines display full or short(yy) year")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "string")]
private DisplayYearTypes DisplayYearType
get
return _DisplayYearType;
set
_DisplayYearType = value;
[Description("Determines minimum year to be displayed in dropdown : Default currentyear - 25")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "int")]
private int MinYear
get
if (MinDate != null)
_minYear = MinDate.Value.Year;
else
_minYear = DateTime.Now.Year - 25;
return _minYear;
//set
// _minDisplayYear = value;
[Description("Determines maximum year to be displayed in dropdown : Default currentyear")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "int")]
private int MaxYear
get
if (MaxDate != null)
_maxYear = MaxDate.Value.Year;
else
_maxYear = DateTime.Now.Year;
return _maxYear;
//set
// _maxDisplayYear = value;
private string DateControlClientId
get
if (DisplayControl == DisplayControls.Dropdown)
_dateControlClientId = hdnDate.ClientID;
else
_dateControlClientId = txtDate.ClientID;
return _dateControlClientId;
[Description("Determines minimum month of min date : default 1")]
[Category("DateTime Selection"), DefaultValue(1)]
private int minMonth
get
if (MinDate != null)
_minMonth = MinDate.Value.Month;
else
_minMonth = 1;
return _minMonth;
[Description("Determines max months of max date: Default 12")]
[Category("DateTime Selection"), DefaultValue(12)]
private int maxMonth
get
if (MaxDate != null)
_maxMonth = MaxDate.Value.Month;
else
_maxMonth = 1;
return _maxMonth;
[Description("Determines minimum day : Defualt 1")]
[Category("DateTime Selection"), DefaultValue(1)]
private int minDay
get
if (MinDate != null)
_minDay = MinDate.Value.Day;
else
_minDay = 1;
return _minDay;
[Description("Determines max day: Defualt last day of max month")]
[Category("DateTime Selection"), DefaultValue(30)]
private int maxDay
get
if (MaxDate != null)
_maxDay = MaxDate.Value.Day;
else
_maxDay = DateTime.DaysInMonth(MaxYear, maxMonth);
return _maxDay;
#endregion
#region "Public Properties"
/// <summary>
/// The currently selected datetime
/// </summary>
[Category("DateTime Selection")]
public DateTime? SelectedValue
get
DateTime dt = new DateTime();
if (DisplayControl == DisplayControls.TextBox && txtDate.Text != "")
DateTime.TryParse(txtDate.Text, out dt);
else if (DisplayControl == DisplayControls.Dropdown && hdnDate.Value != "")
DateTime.TryParse(hdnDate.Value, out dt);
if (dt != null && dt != new DateTime())
_SelectedDate = dt;
else
_SelectedDate = null;
return _SelectedDate;
set
if (!value.HasValue)
txtDate.Text = "";
hdnDate.Value = "";
else
if (value != null && MinDate != null && value < MinDate)
throw new ArgumentOutOfRangeException("SelectedValue", SelectedDate_LessThan_MinDate);
if (value != null && MaxDate != null && value > MaxDate)
throw new ArgumentOutOfRangeException("SelectedValue", SelectedDate_GreaterThan_MaxDate);
string dateFormat = this.DateTimeFormat;
//if ( dateFormat == "Auto")
// dateFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
if (DisplayControl == DisplayControls.TextBox)
txtDate.Text = value.Value.ToString(dateFormat);
else if (DisplayControl == DisplayControls.Dropdown)
hdnDate.Value = value.Value.ToString(dateFormat);
_SelectedDate = value;
if (DisplayControl == DisplayControls.Dropdown)
setDropDownValue(value);
[Description("Determines display textbox or dropdowns")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayModes), "TextBox")]
public DisplayControls DisplayControl
get { return _DisplayControl; }
set { _DisplayControl = value; }
[Description("Determines how the datepicking option is activated")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayModes), "ImageButton")]
public DisplayModes DisplayMode
get { return _DisplayMode; }
set { _DisplayMode = value; }
[Description("Determines what datetimepicker should return")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "DateTime")]
public DisplayTypes DisplayType
get
return _DisplayType;
set
_DisplayType = value;
[Description("Increment minute factor when using the time picker.")]
[Category("DateTime Selection"), DefaultValue(1)]
public int StepMinutes
get
return _StepMinutes;
set
_StepMinutes = value;
[Description("Increment hour factor when using the time picker.")]
[Category("DateTime Selection"), DefaultValue(1)]
public int StepHours
get
return _StepHours;
set
_StepHours = value;
private string _DateTimeFormat = CultureInfo.CurrentCulture != null ? CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern : "dd/MM/yyyy";
[Description("Determines the Date Format used. Auto uses CurrentCulture.DateTimeFormat.ShortDatePattern. Format: MM month, dd date, yyyy year symbol")]
[Category("DateTime Selection"), DefaultValue("dd/MM/yyyy")]
public string DateTimeFormat
get
return _DateTimeFormat;
set
_DateTimeFormat = value;
[Description("Minumum allowable date. Leave blank to allow any date")]
[Category("DateTime Selection"), DefaultValue(typeof(DateTime?), null)]
public DateTime? MinDate
get
return _MinDate;
set
if (value != null && SelectedValue != null && value > SelectedValue)
throw new ArgumentOutOfRangeException("MinDate", MinDate_GreaterThan_SelectedDate);
_MinDate = value;
[Description("Maximum allowable date. Leave blank to allow any date.")]
[Category("DateTime Selection"), DefaultValue(typeof(DateTime?), null)]
public DateTime? MaxDate
get
return _MaxDate;
set
if (value != null && SelectedValue != null && value < SelectedValue)
throw new ArgumentOutOfRangeException("MaxDate", MaxDate_LessThan_SelectedDate);
_MaxDate = value;
[Description("Client event handler fired when a date is selected")]
[Category("DateTime Selection"), DefaultValue("")]
public string OnClientSelect
get
return _OnClientSelect;
set
_OnClientSelect = value;
[Description("Url to a Calendar Image. Applies only if the DisplayMode = ImageButton")]
[Category("DateTime Resource"), DefaultValue("../Images/calendar.png")]
public string ButtonImage
get { return _ButtonImage; }
set { _ButtonImage = value; }
[Category("DateTime Resource"), Description("The CSS that is used for the calendar or empty for default."), DefaultValue("WebResource")]
public string CalendarCss
get { return _CalendarCss; }
set { _CalendarCss = value; }
[Description("Location for the calendar JavaScript or empty for default.")]
[Category("DateTime Resource"), DefaultValue("../scripts/timepicker.js")]
public string CalendarJs
get { return _CalendarJs; }
set { _CalendarJs = value; }
[Description("Determines what to Display full Month name or short month name")]
[Category("DateTime Selection"), DefaultValue(typeof(DisplayTypes), "string")]
public DisplayMonthTypes DisplayMonthType
get
return _DisplayMonthType;
set
_DisplayMonthType = value;
[Description("Display static label for msg below date control")]
[Category("DateTime Selection"), DefaultValue(true)]
public bool DisplayMessageLable
get { return _DisplayMessageLabel; }
set { _DisplayMessageLabel = value; }
[Bindable(true)]
[DefaultValue("false")]
public override short TabIndex
get
return _tabIndex;
set
_tabIndex = value;
ddlDay.TabIndex = value;
ddlMonth.TabIndex = value;
ddlYear.TabIndex = value;
imgCal.TabIndex = value;
#endregion
#endregion
#region "Events"
public DateTimePicker()
this.Width = Unit.Pixel(80);
/// <summary>
/// Load all controls
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
base.OnInit(e);
//Controls.Clear();
//CreateAndAddControls();
/// <summary>
/// Add Child controls - Dropdowns and textbox;
/// </summary>
protected override void CreateChildControls()
base.CreateChildControls();
Controls.Clear();
CreateAndAddControls();
/// <summary>
/// Load all controls
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
base.OnLoad(e);
if (DisplayControl == DisplayControls.Dropdown)
if (ddlDay.Items.Count == 0 || ddlMonth.Items.Count == 0 || ddlYear.Items.Count == 0 || !Page.IsPostBack)
FillDropdowns();
generateDisplayMessage();
protected override void LoadViewState(object savedState)
base.LoadViewState(savedState);
protected override void LoadControlState(object savedState)
base.LoadControlState(savedState);
protected override object SaveViewState()
if (HasControls() && Page.IsPostBack)
ddlDay.SelectedValue = "11";
object obj = base.SaveViewState();
return obj;
protected override void TrackViewState()
base.TrackViewState();
/// <summary>
/// Most of the work happens here for generating the hook up script code
/// </summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
base.OnPreRender(e);
// Register resources
this.RegisterResources();
string script = GenerateScript();
Page.ClientScript.RegisterStartupScript(this.GetType(), "_cal" + this.ID, script, true);
/// <summary>
/// Render Control
/// </summary>
/// <param name="writer"></param>
public override void RenderControl(HtmlTextWriter writer)
if (this.DisplayMode != DisplayModes.Inline)
base.RenderControl(writer);
else
writer.Write("<div id='" + this.ClientID + "Div'></div>");
if (HttpContext.Current == null)
if (this.DisplayMode == DisplayModes.Button)
writer.Write(" <input type='button' value='...' style='width: 20px; height: 20px;' />");
else if ((this.DisplayMode == DisplayModes.ImageButton))
string img;
if (this.ButtonImage == "WebResource")
img = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "jQueryDatePicker.Resources.calendar.png");
else
img = this.ResolveUrl(this.ButtonImage);
writer.AddAttribute(HtmlTextWriterAttribute.Src, img);
writer.AddAttribute("hspace", "2");
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
/// <summary>
/// Render Control
/// </summary>
/// <param name="writer"></param>
protected override void Render(HtmlTextWriter writer)
RenderControls(writer);
#endregion
#region "Methods"
/// <summary>
/// Set properties of control
/// </summary>
private void CreateAndAddControls()
txtDate.ID = "_txtDate";
txtDate.CssClass = "dpDate";
ddlDay.ID = "_ddlDay";
ddlMonth.ID = "_ddlMonth";
ddlYear.ID = "_ddlYear";
imgCal.ID = "_imgCal";
imgCal.CssClass = "trigger";
imgCal.ImageUrl = this.ButtonImage;
//imgCal.Visible = false;
hdnDate.ID = "_hdnDate";
lblMsg.ID = "_lblMsg";
lblMsg.CssClass = "MsgLabel";
if (DisplayControl == DisplayControls.Dropdown)
txtDate.Visible = false;
this.Controls.Add(ddlDay);
this.Controls.Add(ddlMonth);
this.Controls.Add(ddlYear);
this.Controls.Add(hdnDate);
else
txtDate.Visible = true;
this.Controls.Add(txtDate);
this.Controls.Add(imgCal);
this.Controls.Add(lblMsg);
/// <summary>
/// Add Controls to the control
/// </summary>
private void RenderControls(HtmlTextWriter writer)
//if (ChildControlsCreated)
// return;
AddAttributesToRender(writer);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "datePickerTable", false);
writer.RenderBeginTag(HtmlTextWriterTag.Table);//start of table
writer.RenderBeginTag(HtmlTextWriterTag.Tr);//start of tr1
if (DisplayControl == DisplayControls.Dropdown)
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlDay.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlMonth.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlYear.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
hdnDate.RenderControl(writer);
writer.RenderEndTag();
else
writer.RenderBeginTag(HtmlTextWriterTag.Td);
txtDate.RenderControl(writer);
writer.RenderEndTag();
writer.RenderBeginTag(HtmlTextWriterTag.Td);
//Control ltrl1 = new LiteralControl();
//writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "None");
//writer.RenderBeginTag(HtmlTextWriterTag.Div);
////ltrl1.RenderControl(writer);
//imgCal.RenderControl(writer);
//writer.RenderEndTag();//end of div
writer.Write("<div style=\"display:none\">");
imgCal.RenderControl(writer);
writer.Write("</div>");
writer.RenderEndTag();
writer.RenderEndTag();//end of tr1
writer.RenderBeginTag(HtmlTextWriterTag.Tr);//start of tr
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "4", false);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
lblMsg.RenderControl(writer);
writer.RenderEndTag();
writer.RenderEndTag();// end of tr2
writer.RenderEndTag();// end of table
//string newTable = "<table class='datePickerTable'";
//string endTable = "</table>";
//string newTr = "<tr>";
//string endTr = "</tr>";
//string newTd = "<td>";
//string endTd = "</td>";
////Controls.Clear();
//InitControls();
//Controls.Add(new LiteralControl(newTable + newTr + newTd));
//if (DisplayControl == DisplayControls.Dropdown)
// Controls.Add(ddlDay);
// Controls.Add(new LiteralControl(endTd + newTd));
// Controls.Add(ddlMonth);
// Controls.Add(new LiteralControl(endTd + newTd));
// Controls.Add(ddlYear);
// Controls.Add(new LiteralControl(endTd + newTd));
//Controls.Add(txtDate);
//Controls.Add(hdnDate);
//Controls.Add(new LiteralControl(endTd + newTd));
//Controls.Add(new LiteralControl("<div style=\"display:none\">"));
//Controls.Add(imgCal);
//Controls.Add(new LiteralControl("</div>"));
//Controls.Add(new LiteralControl(endTd + endTr));
//Controls.Add(new LiteralControl(newTr + "<td colspan=4>"));
//Controls.Add(lblMsg);
//Controls.Add(new LiteralControl(endTd + endTr + endTable));
/// <summary>
/// Code that embeds related resources (.js and css)
/// </summary>
/// <param name="scriptProxy"></param>
protected void RegisterResources()
// Load the calandar script
string script = this.CalendarJs;
// Load jQuery Calendar Scripts
if (script == "WebResource")
Page.ClientScript.RegisterClientScriptResource(this.GetType(), "jQueryDatePicker.Resources.ui.datepicker.js");
else if (!string.IsNullOrEmpty(script))
Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "__jqueryCalendar", this.ResolveUrl(script));
// Load the related CSS reference into the page
script = this.CalendarCss;
if (script == "WebResource")
script = Page.ClientScript.GetWebResourceUrl(this.GetType(), "jQueryDatePicker.Resources.ui.datepicker.css");
else if (!string.IsNullOrEmpty(script))
script = this.ResolveUrl(this.CalendarCss);
// Register Calendar CSS 'manually'
string css = @"<link href=""" + script + @""" type=""text/css"" rel=""stylesheet"" />";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "_calcss", css, false);
/// <summary>
/// Converts a date to a JavaScript date string in UTC format
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
private static string EncodeJsDate(DateTime date)
return "new Date(\"" + date.ToString("U") + " UTC" + "\")";
/// <summary>
/// Generate Javascript for Datepicker plugin
/// </summary>
/// <returns></returns>
private string GenerateScript()
// To capture and map the various option parameters
StringBuilder sbOptions = new StringBuilder(512);
sbOptions.Append("{");
//jQuey Script
StringBuilder sbStartupScript = new StringBuilder(400);
sbStartupScript.AppendLine("jQuery(document).ready( function() {");
string dateFormat = this.DateTimeFormat;
if (!string.IsNullOrEmpty(dateFormat))
dateFormat = this.DateTimeFormat.Replace("MMM", "M").Replace("MM", "mm");
sbOptions.Append("dateFormat: '" + dateFormat + "'");
//string onSelect = this.OnClientSelect;
if (this.DisplayMode == DisplayModes.Button)
sbOptions.Append(",showOnFocus: false, showTrigger: '<button type=\"button\" class=\"trigger\">...</button>'");
else if (this.DisplayMode == DisplayModes.ImageButton)
string img = this.ButtonImage;
if (img == "WebResource")
img = Page.ClientScript.GetWebResourceUrl(this.GetType(), "jQueryDatePicker.Resources.calendar.png");
else
img = this.ResolveUrl(this.ButtonImage);
sbOptions.Append(",showOnFocus: false, showTrigger: '#" + imgCal.ClientID + "'");
sbOptions.Append(", onSelect: DateSelectedFromCalendar ");
if (this.MinDate.HasValue)
sbOptions.Append(",minDate: new Date(" + MinDate.Value.Year.ToString() + "," + (MinDate.Value.Month - 1).ToString() + "," + MinDate.Value.Day.ToString() + ")");
if (this.MaxDate.HasValue)
sbOptions.Append(",maxDate: new Date(" + MaxDate.Value.Year.ToString() + "," + (MaxDate.Value.Month - 1).ToString() + "," + MaxDate.Value.Day.ToString() + ")");
sbOptions.Append(",yearRange:' " + this.MinYear.ToString() + ":" + this.MaxYear.ToString() + "'");
//end of options
sbOptions.Append("}");
// Write out initilization code for calendar
if (this.DisplayMode != DisplayModes.Inline)
sbStartupScript.AppendLine("var cal = jQuery('#" + this.DateControlClientId + "').datepick(" + sbOptions.ToString() + ");");
else
sbStartupScript.AppendLine("var cal = jQuery('#" + this.ClientID + "Div').datepick(" + sbOptions.ToString() + ");");
sbStartupScript.AppendLine("var dp = jQuery.datepicker;");
if (this.SelectedValue.HasValue && this.SelectedValue.Value > new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Utc))
sbStartupScript.AppendLine("dp.setDateFor(cal[0],new Date('" + txtDate.Text + "'));");
sbStartupScript.AppendLine("dp.reconfigureFor(cal[0]);");
//******************* When dropdown changes then reflect it in calendar
if (DisplayControl == DisplayControls.Dropdown)
sbStartupScript.AppendLine("\r\n\r");
sbStartupScript.Append("$('#" + ddlDay.ClientID);
sbStartupScript.Append(",#" + ddlMonth.ClientID);
sbStartupScript.Append(",#" + ddlYear.ClientID + "').change(function() {");
// disable months and days when they are less then day months of minimum date
sbStartupScript.Append("$ddlDay=$('#" + ddlDay.ClientID + "');");
sbStartupScript.Append("$ddlMonth=$('#" + ddlMonth.ClientID + "');");
sbStartupScript.Append("$ddlYear=$('#" + ddlYear.ClientID + "');");
sbStartupScript.AppendLine("var minYear=" + this.MinYear.ToString() + ";");
///disable months of minimum year which are less then minumum date month
sbStartupScript.AppendLine("if($ddlYear.val()<=minYear && $('#" + this.DateControlClientId + "').val!=''){ alert('true');");
sbStartupScript.AppendLine("var minMonth=" + this.minMonth.ToString() + ";");
sbStartupScript.AppendLine("if($ddlMonth.val()<=minMonth){");//start of if of minMonth
sbStartupScript.AppendLine("$ddlMonth.val(minMonth);");
sbStartupScript.AppendLine("var minDay=" + this.minDay.ToString() + ";");
sbStartupScript.AppendLine("$ddlMonth.find('option:lt('+minMonth+')').hide();");
sbStartupScript.AppendLine("if($ddlDay.val()<=minDay)");
sbStartupScript.AppendLine("$ddlDay.val(minDay);");
sbStartupScript.AppendLine("}");// end of if of minMonth
sbStartupScript.AppendLine("else {");
sbStartupScript.AppendLine("$ddlDay.find('option').show();");
sbStartupScript.AppendLine("}");// end of else part of min month
sbStartupScript.AppendLine("$ddlDay.find('option:lt('+minDay+')').hide();");
sbStartupScript.AppendLine("}");// end of if part of min Year
sbStartupScript.AppendLine("else {");
sbStartupScript.AppendLine("$ddlMonth.find('option').show();");
sbStartupScript.AppendLine("}");// end of else part of min Year
///set date in calendar
sbStartupScript.AppendLine();
sbStartupScript.Append("$('#" + this.DateControlClientId + "').datepick('setDate', new Date(\n\r\r ");
sbStartupScript.Append("$('#" + ddlYear.ClientID + "').val(),");
sbStartupScript.Append("$('#" + ddlMonth.ClientID + "').val()-1,");
sbStartupScript.Append("$('#" + ddlDay.ClientID + "').val()));");
sbStartupScript.AppendLine("} );");
//******************* When calendar changes then reflect it in dropdown
sbStartupScript.AppendLine("\r\n\r");
sbStartupScript.AppendLine("function DateSelectedFromCalendar(dates) {");
if (DisplayControl == DisplayControls.Dropdown)
sbStartupScript.AppendLine("$('#" + ddlDay.ClientID + "').val(dates.length ? dates[0].getDate() : '');");
sbStartupScript.AppendLine("$('#" + ddlMonth.ClientID + "').val(dates.length ? dates[0].getMonth() +1 : '');");
sbStartupScript.AppendLine("$('#" + ddlYear.ClientID + "').val(dates.length ? dates[0].getFullYear() : '');");
if (!string.IsNullOrEmpty(this.OnClientSelect))
sbStartupScript.AppendLine(this.OnClientSelect + "();");
sbStartupScript.AppendLine("}");
//******************* Validation Script
sbStartupScript.AppendLine("\r\n\r");
sbStartupScript.AppendLine("$('form').validate({");
sbStartupScript.AppendLine("errorPlacement: $.datepick.errorPlacement,");
sbStartupScript.AppendLine("rules: {");
sbStartupScript.AppendLine(this.DateControlClientId + ": {");//start of format picker
sbStartupScript.AppendLine("required: true, dpDate: true}");//end of formate picker
sbStartupScript.AppendLine("}, ");// end of rules
sbStartupScript.AppendLine("messages: {");
sbStartupScript.AppendLine(this.DateControlClientId + ": 'Please enter a valid date (" + this.DateTimeFormat + ")'");
sbStartupScript.AppendLine("}");// end of messages
sbStartupScript.AppendLine("});"); //end of validate function
//******************* close document ready function
sbStartupScript.AppendLine("} );");
return sbStartupScript.ToString();
/// <summary>
/// Fill day month and year dropdown
/// </summary>
private void FillDropdowns()
//Fill Day Dropdown
ListItem liDay = new ListItem("Day", "0");
ddlDay.Items.Add(liDay);
for (int i = 1; i <= 31; i++)
ListItem li = new ListItem(i.ToString(), i.ToString());
ddlDay.Items.Add(li);
//Fill Month Dropdown
ListItem liMonth = new ListItem("Month", "0");
ddlMonth.Items.Add(liMonth);
string monthName = string.Empty;
for (int i = 1; i <= 12; i++)
switch (DisplayMonthType)
case DisplayMonthTypes.Full:
monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i);
break;
case DisplayMonthTypes.Short:
monthName = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(i);
break;
ListItem li = new ListItem(monthName, i.ToString());
ddlMonth.Items.Add(li);
//Fill Year Dropdown
ListItem liYear = new ListItem("Year", "0");
ddlYear.Items.Add(liYear);
string yearDisplay = string.Empty;
for (int i = MinYear; i <= MaxYear; i++)
switch (DisplayYearType)
case DisplayYearTypes.Full:
yearDisplay = i.ToString();
break;
case DisplayYearTypes.Short:
yearDisplay = i.ToString().Substring(2);
break;
ListItem li = new ListItem(yearDisplay, i.ToString());
ddlYear.Items.Add(li);
setDropDownValue(this.SelectedValue);
private void generateDisplayMessage()
if (this.DisplayMessageLable)
if (this.DisplayControl == DisplayControls.TextBox)
lblMsg.Text = this.DateTimeFormat;
if (this.MinDate != null && this.MinDate.Value != new DateTime())
lblMsg.Text += " From " + this.MinDate.Value.ToString(this.DateTimeFormat);
if (this.MaxDate != null && this.MaxDate.Value != new DateTime())
lblMsg.Text += " To " + this.MaxDate.Value.ToString(this.DateTimeFormat);
private void setDropDownValue(DateTime? dt)
if (ddlDay.Items.Count != 0 && ddlMonth.Items.Count != 0 && ddlYear.Items.Count != 0)
if (dt != null && dt != new DateTime())
ddlDay.SelectedValue = ddlDay.Items.FindByValue(dt.Value.Day.ToString()).Value;
ddlMonth.SelectedValue = ddlMonth.Items.FindByValue(dt.Value.Month.ToString()).Value;
ddlYear.SelectedValue = ddlYear.Items.FindByValue(dt.Value.Year.ToString()).Value;
else
ddlDay.SelectedValue = "0";
ddlMonth.SelectedValue = "0";
ddlYear.SelectedValue = "0";
#endregion
}Usage Of Code in .ascx<cc2:DateTimePicker ID="dtpDOB" DisplayType="Date" DisplayMode="ImageButton" ButtonImage="../Images/calendar.png" runat="server"Changing Value from .cs file dtpDOB.SelectedValue = DateTime.Parse("01/01/2001");It is not reflected in screenHello,
According to your code, it's an ASP.NET user control problem. Please post in
ASP.NET forums where more web developers will give you help.
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Trying to load a javascript link from text file into a dynamic textfile
Can anyone help me with this problem? Im trying to load in a
newsfeed from freshcontent.net into my text field. If i put this
javascript link on an html page, the page shows correctly, which is
im supposed to get 3 dynamic links with news content headlines.
Please view the link to see what i mean:
http://www.freshcontent.net/directory/real-estate/real_estate.html
Now, i cannot get this same type of display behavior in my
text field if i just paste into my text file the javascript link
thats supposed to bring up the 3 headlines. It is my understanding,
that flash cannot do this without some sort of specific
actionscripting, that involves asfusion, and/or externalInterface.
Im not sure exactly how to go about setting this up to make this
work. My current code looks like this:
If anybody could tell me where im going wrong and what i
should change in order to get the desired result im going for, Id
very much appreciate it. Thankswell sorry there fanmap - but I don't think you're going to
be able to get this to work. here's why: the link points to a php
file - which gathers dynamic info from a DB - the return from the
php is generating a string that is based on the DOM and
'constructs' a javascript method that in turn writes to the html
document. although we can embed html into a textField in Flash
there are a limited number of supported html tags - and JS methods
will not operate internally. in addition, (i'm not certain someone
correct this if i'm off) there's no way to 'change' the output of
the php call, therefore you will not be able to read the return
because it is designed to use the DOM and write solely to the
current document. Even if you were to access the JS method from the
swf file (which one can) it will still only write the content of
the php return to the html document - and the output is not
compatible with the textField class.
Maybe you are looking for
-
How to write text name of parameters / select options in ABAP list??
Hi gurus, i must read the text name of parameterd / select options in ABAP program and write it in a list of the same program for log.......how can i do it?? Thanks in advance! Best regards! Ferdinando Message was edited by: Ferdinando Sellit
-
Validation for not due items.
I want to make a validation that when a vendor invoice is cleared and if it is not due (i.e. days in arrears are negative), system should issue a message that the item is not due. I tried with : pre-req : transaction code=F-53 check : days in arrear
-
What are the points to be considered while upgarding from 8i to 9i or 10g? Any standrad feature comparison available on all these 3 ?
-
OBIEE 11.1.1.7 and external OpenLDAP provider
Hi, my organization recently decided to upgrade OBIEE from version 11.1.1.6 to 11.1.1.7. I've made installation on our DEV environment followed the instructions prepared during previous installation (11.1.1.6). The installation went without any probl
-
Running a sequence programatically
Hi, I am trying to run a sequence programatically (C#). Following is my psuedo code: Execution exec = TSEngine.NewExecution(SeqFile, "MainSequence", null, false, 0, null, null, null); exec.WaitForEndEx(-1, false, null, null);