function parseDate(input, format)
{
format = format || 'dd/mm/yyyy'; // somedefault format
var parts = input.match(/(\d+)/g),
i = 0, fmt = {};
// extract date-part indexes from the format
format.replace(/(yyyy|dd|mm)/g, function(part) { fmt[part] = i++; });
return new Date(parts[fmt['yyyy']], parts[fmt['mm']]-1, parts[fmt['dd']]);
}
Usage
parseDate('01-31-2010', 'mm-dd-yyyy');
parseDate('31/01/2010', 'dd/mm/yyyy');
parseDate('2010/01/31');
Search This Blog
Tuesday, June 5, 2012
Invalid object name "Tempdb.dbo.ASPStateTempApplications"
Execute the below script to solve the error : Invalid object name = 'tempdb.dbo.ASPStateTempApplications'.
USE [ASPState]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[CreateTempTables]
SELECT 'Return Value' = @return_value
GO
USE [ASPState]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[CreateTempTables]
SELECT 'Return Value' = @return_value
GO
Monday, June 4, 2012
how to populate cascading dropdownlist in javascript?
You can force it to populate by setting a different index.
<script type="text/javascript">
function pageLoad()
{
var cde = $find('test_cascade');
cde.set_contextKey("not raymond");
var parent = $get(cde.get_ParentControlID());
var index = parent.selectedIndex;
parent.selectedIndex = -1;
cde._onParentChange(null, false);
parent.selectedIndex = index;
cde._onParentChange(null, false);
}
</script>
<asp:DropDownList id= "ddl_state" runat="server" ></asp:DropdownList>
<asp:DropDownList id= "ddl_dist" runat="server" ></asp:DropdownList>
<ajaxToolkit:CascadingDropDown id="CascadingDropDown1" runat="server" ServicePath="WebService.asmx" ServiceMethod="GetAllDistrict" ParentControlID="ddl_state" TargetControlID="ddl_dist" Category="Districts" UseContextKey="true" LoadingText="Loading District" PromptText="Select a District" BehaviorID="test_cascade"> </ajaxToolkit:CascadingDropDown>
<script type="text/javascript">
function pageLoad()
{
var cde = $find('test_cascade');
cde.set_contextKey("not raymond");
var parent = $get(cde.get_ParentControlID());
var index = parent.selectedIndex;
parent.selectedIndex = -1;
cde._onParentChange(null, false);
parent.selectedIndex = index;
cde._onParentChange(null, false);
}
</script>
<asp:DropDownList id= "ddl_state" runat="server" ></asp:DropdownList>
<asp:DropDownList id= "ddl_dist" runat="server" ></asp:DropdownList>
<ajaxToolkit:CascadingDropDown id="CascadingDropDown1" runat="server" ServicePath="WebService.asmx" ServiceMethod="GetAllDistrict" ParentControlID="ddl_state" TargetControlID="ddl_dist" Category="Districts" UseContextKey="true" LoadingText="Loading District" PromptText="Select a District" BehaviorID="test_cascade"> </ajaxToolkit:CascadingDropDown>
Friday, May 18, 2012
How to check your page is valid?
function ValidatePage() {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}
Thursday, May 3, 2012
How to rerturn value from showmodaldialog
Using the following javascript code you can return a variant value from modaldialog window to parent window.
When you call showModalDialog you do this:
Code:
var oReturnValue = window.showModalDialog("subDoc.html",argsVariable, "dialogWidth:300px; dialogHeight:200px; center:yes");
Within showModalDialog, assuming your textboxes have IDs of "txtForename" and "txtSurname":
Code:
function terminate()
{
var o = new Object();
o.forename = document.getElementById("txtForename").value;
o.surname = document.getElementById("txtSurname").value;
window.returnValue = o;
}
Then continuing in your main window:
Code:
alert(oReturnValue.forename + "\n" + oReturnValue.surname);
When you call showModalDialog you do this:
Code:
var oReturnValue = window.showModalDialog("subDoc.html",argsVariable, "dialogWidth:300px; dialogHeight:200px; center:yes");
Within showModalDialog, assuming your textboxes have IDs of "txtForename" and "txtSurname":
Code:
function terminate()
{
var o = new Object();
o.forename = document.getElementById("txtForename").value;
o.surname = document.getElementById("txtSurname").value;
window.returnValue = o;
}
Then continuing in your main window:
Code:
alert(oReturnValue.forename + "\n" + oReturnValue.surname);
Wednesday, April 11, 2012
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.re
Error Message:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed
Resaon :
AjaxControlToolkit’s control load reference refers to the base System.Web.UI.Control method which is present as a part of the ASP.NET AJAX Libraries and those libraries are referenced only when the ScriptManager is referenced in the page.
Solution:
Add ScriptManager in the page and this error would be resolved.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed
Resaon :
AjaxControlToolkit’s control load reference refers to the base System.Web.UI.Control method which is present as a part of the ASP.NET AJAX Libraries and those libraries are referenced only when the ScriptManager is referenced in the page.
Solution:
Add ScriptManager in the page and this error would be resolved.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Saturday, November 5, 2011
How to check that a page is valid using javascript.
<input type="submit" value="Submit" onclick"ValidatePage();" />
<script type="text/javascript">
function ValidatePage() {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}
</script>
<script type="text/javascript">
function ValidatePage() {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}
if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}
</script>
Subscribe to:
Posts (Atom)
