Wednesday, November 17, 2010

open radwindow using radmenu item click within a template column of radgrid

first, make sure you have "ClientDataKeyNames="Id" " added into the Master Table View of the radgrid

then implement the following javascript:

function OpenRecordBreakdown(Id)
{
var oWnd = radopen("RecordBreakDown.aspx?Id=" + , "rwRecordBreakDown");
oWnd.setSize(900, 600);
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Maximize + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Close)
oWnd.Center();
}


var lastClickedItem = null;
var clickCalledAfterRadprompt = false;
var clickCalledAfterRadconfirm = false;
function onClientButtonClicking(sender, args) {

if (args.get_item().get_text() == "Delete") {
if (!clickCalledAfterRadconfirm) {
args.set_cancel(true);
lastClickedItem = args.get_item();
radconfirm("Are you sure you want to delete this Item?", confirmCallbackFunction);
}
}

if (args.get_item().get_text() == "Record Breakdown") {
var cell = sender.get_element().parentNode.parentNode;
rowindex = cell.rowIndex; //The row index may vary based on the grid structure.
var grid = $find("<%=rgList.ClientID %>");
var MasterTable = grid.get_masterTableView();
var id = MasterTable.get_dataItems()[rowindex - 2].getDataKeyValue("Id");

OpenRecordBreakdown(id);

args.set_cancel(true);
}
}

function confirmCallbackFunction(args) {
if (args) {
clickCalledAfterRadconfirm = true;
lastClickedItem.click();
}
else
clickCalledAfterRadconfirm = false;
lastClickedItem = null;
}

Thursday, November 11, 2010

Using radprompt and radconfirm with Telerik navigational controls

Found this article very useful, hope it can help you as well

Using radprompt and radconfirm with Telerik navigational controls

http://www.telerik.com/support/kb/aspnet-ajax/window/using-radprompt-and-radconfirm-with-telerik-navigational-controls.aspx

Wednesday, November 10, 2010

open radwindow in codebehind by radcombobox selectedindexchanged event

ScriptManager.RegisterStartupScript(this, typeof(abc_def_1), "openWin", "openWin('" + ParameterId.ToString() + "');", true);

provide you still need the radwindow manager in .aspx code, and the javascript "openWin"

Monday, October 18, 2010

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEve

"Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."

in my case it is caused by trying to call a radgrid.rebind() in page_load, the radgrid sits inside of a radupdatepanel. In case of postback the code contains client script which caused this security breach. After I put radgrid.rebind() inside !IsPostBack the error disappearred.

Thursday, September 09, 2010

Persist RadGrid Settings

found this class really helpful:
http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html

Tuesday, August 03, 2010

Friday, July 16, 2010

visual studio 2010 issue referencing usercontrol property from container page

When I tried to reference a public property in user control from a container page, the intellisense doesn't seem to be able to pick up the property. Ignore the red curly underline, build the parent page, it worked~

another VS2010 bug?

Tuesday, June 29, 2010

find column value when updating RadGrid item using EditItemTemplate

if (e.CommandName == RadGrid.UpdateCommandName)
{
GridEditableItem editable = e.Item as GridEditableItem;
int TheId= Convert.ToInt32(editable.OwnerTableView.DataKeyValues[editable.ItemIndex]["TheId"].ToString());

Wednesday, May 05, 2010

asp.net logout user

FormsAuthentication.Signout();

Response.Resirect([loginURL]);

Friday, April 23, 2010

T-SQL loop through all rows in a table to add an incremental value

DECLARE @tempTable table(Id INT NOT NULL PRIMARY KEY)
DECLARE @counter INT
INSERT INTO @tempTable SELECT UserId from TestTable
SET @counter = 1
WHILE (@counter < (SELECT COUNT(UserId) FROM @tempTable)+1)
BEGIN
UPDATE TestTable SET TestColumn = '' WHERE Id = (
SELECT a.Id FROM
(SELECT Id, Row_Number() OVER(ORDER BY UserId) AS 'RN' from TestTable) as a
where a.RN = @counter
)
SET @counter = @counter + 1
END

Wednesday, April 21, 2010

RadGrid wont expand after updated to Q1 2010

This is because the detail table is set to "visible=false" during the update process. Not all RadGrid controls in the application get this symptom, not sure why this happens. All you need to do is to change the setting to "visible = true"

Tuesday, April 20, 2010

T-SQL division

I came cross this this issue of failing to do a division with 2 integer values. Stupid enough......

so In order for the division to work i used CAST(value TO FLOAT)

Monday, April 19, 2010

Setup Radwindow on button in code behind

int tempId= 168;
RadWindow rw = rwmTEMP.Windows[0];
rw.Width = System.Web.UI.WebControls.Unit.Pixel(1000);
rw.Height = System.Web.UI.WebControls.Unit.Pixel(1000);
rw.Behaviors = WindowBehaviors.Move | WindowBehaviors.Close | WindowBehaviors.Maximize | WindowBehaviors.Resize;
rw.OpenerElementID = btnOpenWindow.ClientID;

rw.NavigateUrl = "~/xxxxx/abccc.aspx?TempId=" + tempId.ToString();

Thursday, April 01, 2010

add new line in ajaxToolkit:ConfirmButtonExtender's ConfirmText

use the combination of &,#,10, and ; to create a new line

Friday, February 26, 2010

mssql reset table identity

the following script resets the table identity seeding to 99, the next record will have identity of 100

DBCC CHECKIDENT ("[table name]", RESEED, 99);
GO

Friday, February 12, 2010

Monday, February 08, 2010

RadGrid Export Button does not work

if the buttons are located within a RadAjaxPanel or RadUpdatePanel the button must be registered for postback event. This can be done in aspx or code behind:
C#:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(ExportCSVButton);
ASPX:

Thursday, February 04, 2010

sql how to replace the time value in datetime column

update Table1
SET StartDateTime = CONVERT(datetime,
CONVERT(VARCHAR(10),StartDateTime , 101)
+' '+CONVERT(VARCHAR,datepart(HH,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(MI,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(SS,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(Ms,NewStartTime))
)

Wednesday, February 03, 2010

replace time in datetime value c#

I have 2 datetime values: StartDateTime ('11/01/2010 00:00:00') and NewStartTime('12/02/2010 09:30:00 AM'). I want to replace the time value in StartDateTime with the time value in NewStartTime. In order to achieve so I go:
DateTime NewStartDateTime = new DateTime(StartDateTime.Year, StartDateTime.Month, StartDateTime.Day, NewStartTime.Hour, NewStartTime.Minute, NewStartTime.Second);

System.Web.HttpException: Request is not available in this context

this is caused by using "Request["xxx"]"
a quick fix is to use "HttpContext.Current.Request" instead

Wednesday, January 13, 2010

sql replace substring with value from associated table

Update TableA
set ColumnA1 = (select a.ColumnA from
(
"SELECT" REPLACE("t.ColumnA1, t.ColumnA2", (select "ColumnB1 from TableA where ColumnB2= t.ColumnA2))
FROM TableA t
) a
where TableA.ColumnA2 = a.ColumnA2)
GO