Techno Freak Search

Search Results

Friday, August 31, 2012

Load JavaScript from Code Behind File


This Script is used for Load JavaScript through code behind

<div id="uxDiv_ScriptBlock" runat="server" style="display:none;">
<script type="text/javascript">
    function test() {
        alert("here");
    }
</script>
</div>


protected void Page_Load(object sender, EventArgs e)
{
    //register script
    String script = uxDiv_ScriptBlock.InnerText.Replace(Environment.NewLine, "");
    ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Scripts", script, false);
}

Link

Thursday, June 28, 2012

SPWebApplication Vs SPSite Vs SPWeb

SPWebApplication Vs SPSite Vs SPWeb

































For a quick reference: 
  • SPWebApplication is an instance of an IIS Web Application that hosts SharePoint site collections
  • SPSite is a site collection 
  • SPWeb is an instance of a SharePoint Website (or "Site" from the UI), this includes subsites 

SPWebApplication Definition :
-----------------------------------------------
Physically, SPWebApplication represents an IIS load-balanced website containing a custom web.config and a standard set of SharePoint specific files and virtual directories including the *_layouts* directory and the *_controltemplates* directory .


To get reference to target Web Application, you can use :


Uri webAppUrl = new Uri("http://sp2010site");
SPWebApplication webApp = SPWebApplication.Lookup(webAppUrl);



SPSite and SPWeb Definition :
---------------------------------------------------


SPSite and SPWeb are fundamental types in the Server Object Model. They represent a site collection and a website, respectively.


By and large, To work with SharePoint from a browser-based application, your code must first establish the site context or site collection context for requests sent to the server. To return the current site collection, you can use :


SPSite site = SPContext.Current.Site;
To return the web site of the current request, you can use :


SPWeb web = SPContext.Current.Web;


Reference URL :
http://sharepoint.stackexchange.com/questions/23241/getting-my-head-round-spsite-vs-spweb-vs-anything-else
http://sridharu.blogspot.in/2008/02/spsite-vs-spweb-and-spwebapplication.html
http://point2sharepoint.blogspot.in/2011/03/spweb-vs-spsite-vs-spwebapplication_29.html




Wednesday, August 10, 2011

Using SharePoint Data in your LightSwitch Applications


One of the great features of LightSwitch is that it lets you connect to and manipulate data inside of SharePoint. Data can come from any of the built in SharePoint lists like Tasks or Calendar or it can come from custom lists that you create in SharePoint.  .LightSwitch provides the ability to connect to multiple data sources like external databases and SharePoint and relate them together. However when you want to present data from multiple data sources on the same screen you need to tell LightSwitch the order in which you want to save this data.


More Details Refer this link


Saturday, July 9, 2011

BCP Utility + Sql Server 2005 / 2008

Hi

This article is based on bcp (Bulk Copy Processing). BCP utility is generally used to transfer large data into own file format.

For More Details you can visit : http://msdn.microsoft.com/en-us/library/ms162802.aspx

This utility is useful to archiving log which is older then 30 days and It will dump all records to the file. If bcp commands run successfully then only delete command will execute and delete all the archiving records from database.
I have created Stored Procedure for Log Archiving. Please find list of advantage of Log Archive Script:

- Run "SQLInsertScriptForBCP.sql" for Creating Dummy Table for BCP.
- User can pass Table Name, No of Days Older, Path and File Name as parameter
- While Archive log if any error is generated then it will log that error and Delete command will not be executed.
- Automatically retrieve server name.
- You can run this utility on schedule also.
-
That's it.

































Download Link
 


Regards
Pritesh Gandhi.

Reference links:

http://sqlfool.com/2008/12/bcp-basics/

Monday, June 6, 2011

asp.net date validation with three drop down list

Hi,
If you want to do date validation on three drop down list  then please find below is reference and Solution.



var minYear=1900;
var maxYear=2100;

function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } function isDate(strDay,strMonth,strYear ){ var daysInMonth = DaysArray(12) if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)

if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
return false
}

if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}

if (strYear.length != 4 || year==0 || yearmaxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}


return true
}

Retrieve Text and Value of ASP.Net DropDown List + JavaScript

// JavaScript Code

//Diplay the Text and Value of ASP Dropdown List
function DisplayTextAndValueofDropDown() {
var ddlDropDownID = document.getElementById("<%=DropDownList1.ClientID%>");
var DisplayText = ddlDropDownID.options[ddlDropDownID.selectedIndex].text;
var DisplayValue = ddlDropDownID.options[ddlDropDownID.selectedIndex].value;
alert(DisplayText);
alert(DisplayValue);
}


//HTML Code
<asp:dropdownlist id="DropDownList1" runat="server">
<asp:listitem text="TestText" value="TestValue"></asp:listitem>
<asp:listitem text="TempText" value="TempValue"></asp:listitem>
</asp:dropdownlist>

<asp:button id="btnValidation" onclientclick="DisplayTextAndValueofDropDown();" runat="server" text="Click Me"></asp:button>

Tuesday, May 17, 2011

Calling ASP.Net Validator from JavaScript

Hi ,

How to calll asp.net validators conttrol from JavaScript

Here is nice article for Calling ASP.Net Validator from JavaScript


Regards
Pritesh Gandhi

Ratings & Review

Followers