protected void RGUserDisplay_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
try
{
if (e.Item is GridDataItem)
{
GridDataItem gridDataItem = (GridDataItem)e.Item;
GridDataItem item = (GridDataItem)e.Item;
// Get the Linkbutton for Edit Button
LinkButton lnkEditButton = item.FindControl("rglnk_Edit") as LinkButton;
if(lnkEditButton != null)
{
lnkEditButton.Attributes.Add("onClick", "OpenQuestionModelPopup('" + this.popup_page.ClientID + "')");
}
//AdminModule objAdminModule = new AdminModule();
//string auid = "15";
//objAdminModule.DeleteRole(auid);
//LblSno.Text = intSerialNo.ToString();
/* if (strStatusText.ToLower() == "inactive")
{
imgControl.ImageUrl = Server.MapPath("Images/Red.gif");
imgControl.ToolTip = "Inactive";
}
else if (strStatusText.ToLower() == "active")
{
imgControl.ImageUrl = Server.MapPath("Images/Green.jpg");
imgControl.ToolTip = "active";
}*/
//intSerialNo++;
//ViewState["SNo"] = intSerialNo;
}
if (e.Item is GridHeaderItem)
{
GridHeaderItem gridHeaderItem = (GridHeaderItem)e.Item;
if (gridHeaderItem != null)
{
//==========Find the checkbox control in header and add an attribute=============
CheckBox chkAll = (CheckBox)gridHeaderItem.FindControl("chkCheckAll");
chkAll.Attributes.Add("onclick", "javascript:checkAll(this)");
}
}
}
catch (Exception ex)
{
using (objErrorLogs = new ErrorLogs())
{
objErrorLogs.Save_ErrorLog(this.AppRelativeVirtualPath.Replace(this.AppRelativeTemplateSourceDirectory, ""), MethodInfo.GetCurrentMethod().Name, ex.Message);
}
}
}
Wednesday, August 10, 2011
Traverse GridView row
foreach (GridViewRow row in gvPrivileges.Rows)
{
foreach (TableCell cell in row.Cells)
{
CheckBox chkBox = cell.FindControl("chkRoleId") as CheckBox;
if (chkBox != null)
{
if (chkBox.Checked == true)
{
if (!listRoles.Contains(int.Parse(chkBox.ToolTip)))
{
listRoles.Add(int.Parse(chkBox.ToolTip));
}
}
}
}
}
{
foreach (TableCell cell in row.Cells)
{
CheckBox chkBox = cell.FindControl("chkRoleId") as CheckBox;
if (chkBox != null)
{
if (chkBox.Checked == true)
{
if (!listRoles.Contains(int.Parse(chkBox.ToolTip)))
{
listRoles.Add(int.Parse(chkBox.ToolTip));
}
}
}
}
}
Friday, August 5, 2011
Calling the Server method from javascript
1. <script language="javascript">
function callserver() {
var tic = $get("txtNoOfTic").value;
// PageMethods.IsTicketAvailable(tic, OnSuccess, OnFailure);
// here tic is parameter passing to the server method
PageMethods.MyMethod(tic, OnSuccess, OnFailure);
}
function OnSuccess(result) {
if (result) {
alert(result);
$get("txtNoOfTic").select();
}
}
function OnFailure(error) {
alert('failture');
}
</script>
[WebMethod]
public static String MyMethod(string s)
{
return "Welcome";
}
2. Add the WebMethod attribute above the method
3. Add the namespace "using System.Web.Services;"
function callserver() {
var tic = $get("txtNoOfTic").value;
// PageMethods.IsTicketAvailable(tic, OnSuccess, OnFailure);
// here tic is parameter passing to the server method
PageMethods.MyMethod(tic, OnSuccess, OnFailure);
}
function OnSuccess(result) {
if (result) {
alert(result);
$get("txtNoOfTic").select();
}
}
function OnFailure(error) {
alert('failture');
}
</script>
[WebMethod]
public static String MyMethod(string s)
{
return "Welcome";
}
2. Add the WebMethod attribute above the method
3. Add the namespace "using System.Web.Services;"
Showing a PopUp window using Javascript and Div tag
<div id="popup_page" style="border: 1px;position:fixed; background-position:center; top: 15%; left: 20%;border:1px solid #000;z-index: 69; border-style: solid;width: 600px; height: 400px;display:none;background-color: #E2EAFF;" runat="server">
| Login |
</div>
function OpenQuestionModelPopup(fld) {
try {
var pnlSecurtityQues = document.getElementById(fld);
var height = window.innerHeight;
var width = window.innerWidth;
if (pnlSecurtityQues) {
pnlSecurtityQues.style.display = "block";
pnlSecurtityQues.style.left = (width - 800) / 2 - (pnlSecurtityQues.style.width / 2) + "px";
pnlSecurtityQues.style.position = "fixed";
pnlSecurtityQues.style.top = (height - 400) / 2 - (pnlSecurtityQues.style.height / 2) + "px";
pnlSecurtityQues.style.zIndex = 11;
}
return false;
}
catch (e) {
}
}
Friday, July 22, 2011
Textbox readonly property does not postback
When the user sets the textbox property as readonly. It does not have the viewstate. So Value wont display or comes to the server. In order to achieve the output make the textbox readonly after getting the value like this
string s=textbox1.text;
textbo1.readonly=true;
string s=textbox1.text;
textbo1.readonly=true;
Sunday, July 17, 2011
Enabling and Disabling of buttons of prev, next, first and last
private void EnableOrDisableButtons()
{
//=== check the condition total no of pages is greater than zero ==============
if(TotalNumberOfPages >0){
//===== Initial setup =============
if(CurentPageNumber == 0)
{
CurentPageNumber = 1;
}
//===== Now the User is in First Page [Total page is 1] =============
if ((CurentPageNumber == 1) && ( CurentPageNumber == TotalNumberOfPages))
{
lnkFirst.Enabled = lnkPrev.Enabled = false;
}
//===== Now the User is in middle Page =============
else if (CurentPageNumber == 1 && CurentPageNumber < TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = false;
lnkNextButton.Enabled = lnkLastButton.Enabled = true;
}
//===== here also Now the User is in middle Page =============
else if (CurentPageNumber > 1 && CurentPageNumber < TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = lnkNextButton.Enabled = lnkLastButton.Enabled = true;
}
//===== Now the User is in last Page =============
else if (CurentPageNumber == TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = true;
lnkNextButton.Enabled = lnkLastButton.Enabled = false;
}
//======= Setting the page Numbers=======
this.lblPage.Text = CurentPageNumber.ToString() + " of " + TotalNumberOfPages.ToString();
}
{
//=== check the condition total no of pages is greater than zero ==============
if(TotalNumberOfPages >0){
//===== Initial setup =============
if(CurentPageNumber == 0)
{
CurentPageNumber = 1;
}
//===== Now the User is in First Page [Total page is 1] =============
if ((CurentPageNumber == 1) && ( CurentPageNumber == TotalNumberOfPages))
{
lnkFirst.Enabled = lnkPrev.Enabled = false;
}
//===== Now the User is in middle Page =============
else if (CurentPageNumber == 1 && CurentPageNumber < TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = false;
lnkNextButton.Enabled = lnkLastButton.Enabled = true;
}
//===== here also Now the User is in middle Page =============
else if (CurentPageNumber > 1 && CurentPageNumber < TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = lnkNextButton.Enabled = lnkLastButton.Enabled = true;
}
//===== Now the User is in last Page =============
else if (CurentPageNumber == TotalNumberOfPages)
{
lnkFirst.Enabled = lnkPrev.Enabled = true;
lnkNextButton.Enabled = lnkLastButton.Enabled = false;
}
//======= Setting the page Numbers=======
this.lblPage.Text = CurentPageNumber.ToString() + " of " + TotalNumberOfPages.ToString();
}
Subscribe to:
Posts (Atom)