Tuesday, 11 March 2014
Kendo UI Tips
Wednesday, 26 February 2014
Javascript function: Sending MVC Razor parameter containing special characters
Thursday, 1 August 2013
SplitString SQL function returning comma seperated values in a table
Missed on the function that will receive comma seperated IDs and return as a table after splitting them.
CREATE
FUNCTION [dbo].[SplitString] (
@myString
VARCHAR(500),
@deliminator
VARCHAR(10)
)
RETURNS
@ReturnTable
TABLE (
[id] [int]
IDENTITY(1,1) NOT NULL,
[part] [varchar]
(50) NULL
)
AS
BEGIN
DECLARE @iSpaces INT
DECLARE @part VARCHAR(50)
SELECT @iSpaces = CHARINDEX(@deliminator,@myString,0)
WHILE @iSpaces > 0
BEGIN
SELECT @part = SUBSTRING(@myString,0,CHARINDEX(@deliminator,@myString,0))
INSERT INTO @ReturnTable(part)
SELECT @part
SELECT @myString = SUBSTRING(@mystring,CHARINDEX(@deliminator,@myString,0)+ LEN(@deliminator),LEN(@myString) - CHARINDEX(' ',@myString,0))
SELECT @iSpaces = CHARINDEX(@deliminator,@myString,0)
END
IF LEN(@myString) > 0
INSERT INTO @ReturnTable
SELECT @myString
RETURN END
Monday, 29 July 2013
Fetch Cartesian product count from 2 column, both columns containing ID, one containing comma separated IDs
Wednesday, 18 July 2012
Finding ASP.Net control in User Control when using Master Page
The code when NOT using Master page:
ucl_slareport WebUserControl1 = (ucl_slareport)FindControl(reportview);
Repeater ulRepeater1 = (Repeater)WebUserControl1.FindControl("Repeater1");
ulRepeater1.DataSource = reader;
ulRepeater1.DataBind();
Here ucl_slareport is my user control. The control that we are searching is a Repeater control. "reportview" is a new name of the control that we passing from a different function.
When we have the Master Page and trying to find the Repeater control, we first do a FindControl of the ContentPlaceHolder - "MainContent", and then we do a find control of the repeater.
ContentPlaceHolder mpContentPlaceHolder = (ContentPlaceHolder)this.Master.FindControl("MainContent");
ucl_slareport WebUserControl1 = (ucl_slareport)mpContentPlaceHolder.FindControl(reportview);
Repeater ulRepeater1 = (Repeater)WebUserControl1.FindControl("Repeater1");
ulRepeater1.DataSource = reader;
ulRepeater1.DataBind();
So that solves the problem of finding the control from the user control.
Calling an executable file from Website and passing arguments
I had a requirement where I needed to call a exe file from my web application. Also I needed to pass arguments to the exe.
Am calling the exe from my website through a button click. The below code explains:
Webpage.aspx
protected void Button1_Click(object sender, EventArgs e)
{
ProcessStartInfo prodRun = new ProcessStartInfo(ConfigurationManager.AppSettings["exepath"] + "ConClientServer.exe", ConfigurationManager.AppSettings["paths"]);
Process exProducts = new Process();
prodRun.WorkingDirectory = @"C:\my work\EduProj\ConClientServer\bin\Debug\";
prodRun.Arguments = "C:\\Development\\Temp\\NewFilesTemp\\cab.txt";
exProducts = Process.Start(prodRun);
}
The exe file name is mentioned in ProcessStartInfo - "ConClientServer.exe".
WorkingDirectory is where my exe resides.
The 4th line, I passed a single argument. We can however pass multiple argument, separated by comma.
The exe file is called from the location mentioned in the working directory, it accepts the argument from the website as below:
ConClientServer.exe
class Program
{
static void Main(string[] args)
{
Client cl = new Client();
if (args.Length > 0)
{
string path = args[0];
cl.FetchFileFromServer(path);
}
}
}
public class Client
{
public void FetchFileFromServer(string storepath)
{
string downloadpath = storepath;
}
}