Discussions

Value not toggle in JavaScript alert box

+
0 Votes
Locked

Value not toggle in JavaScript alert box

SmartestVEGA
Sorry for a long question, but its simple to understand :-)

I am writing a custom control - Calendar textbox. In the code of the custom control i have added a attribute by the following code:

protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
writer.AddAttribute("isDateControl", "true");
writer.AddAttribute("ShowCalendar", "true");
writer.AddAttribute("MinDate", this.MinDate.ToString("dd/MM/yyyy"));
writer.AddAttribute("MaxDate", this.MaxDate.ToString("dd/MM/yyyy"));
if (string.IsNullOrEmpty(this.ErrorMessage))
{
this.ErrorMessage = "Date should be between " + this.MinDate.ToString("dd/MM/yyyy") + " and "
+ this.MaxDate.ToString("dd/MM/yyyy");
}
writer.AddAttribute("ErrorMessage", this.ErrorMessage);
writer.AddAttribute("maxlength", "10");
if (this.Width.IsEmpty)
{
writer.AddStyleAttribute("width", "80px");
}
}

Here I have added the attribute named ShowCalendar.

I have defined the property as below in the same cs file

public bool ShowCalendar
{
get
{
return _IsShowCalendar;
}
set
{
_IsShowCalendar = true;
}
}

I have one js where i am calling this above property values as shown below:

base.OnPreRender(e);
System.Web.UI.ClientScriptManager cs = this.Page.ClientScript;
cs.RegisterClientScriptResource(typeof(WebDate), "WebControls.WebDate.WebDate.js");

Inside JS..i put the alert box to get the value of the property named
"ShowCalendar"

Shown below :

function Submit() {
var intCnt, obj;
try {
for (intCnt = 0; intCnt < Textbox_Validators.length; intCnt++) {
obj = document.getElementById(Textbox_Validators[intCnt]);
if (obj != null)
{
if (!obj.disabled && obj.style.display != 'none')
{
if (obj.getAttribute("isDateControl") == "true")
{
var status = ValidatorPartDate(obj);
if (!status)
{
return false;
}
}
else
{
var status = EvaluateInputMask(obj, true, obj.getAttribute("ErrorMessage"), obj.getAttribute("CustomExpression"));
if (!status)
{
return false;
}
}
}
if(obj.getAttribute("ShowCalendar") == "false")
{
alert(obj.getAttribute("_IsShowCalendar"));
}
else
{
alert(obj.getAttribute("_IsShowCalendar"));
}
}
}
return true;
}
catch (e) {
alert(e.message);
return false;
}

Till now no issues ..all fine .. I can see the value of "ShowCalendar" attribute from JS alert box, But when i change the value to true to false or vice versa manually in the html tag shown below:

<tsg:WebDate ShowCalendar="false" runat="server"> </tsg:WebDate>

Value is not getting toggled from the JavaScript alert box.

Could you please tell me what the issue , why the value is not toggling?