Posts

How do I find the Client ID of control within an ASP.NET GridView?

<asp:TemplateField> <ItemTemplate> <asp:TextBox ID = "textDateSent" runat = "server" > </asp:TextBox> <input type="button" value='Today' onclick="setToday(' <% # ((GridViewRow)Container).FindControl("textDateSent").ClientID %>');" /> </ItemTemplate> </asp:TemplateField>

How to make eachcontrol inside update panel to readonly.

private static void DisableControl(System.Web.UI.Control control)         {             System.Reflection.PropertyInfo enProp = control.GetType().GetProperty("Enabled");             if (enProp != null)             {                 enProp.SetValue(control, false, null);             }             foreach (System.Web.UI.Control ctrl in control.Controls)             {                 DisableControl(ctrl);             }  ...

Delete gridview row inside repeater by javascript onclient click in asp.net

//Add this in c# code to add client event in button then write your delete code on repeater itemcommand protected void GrdImageDetail_RowDataBound(object sender, GridViewRowEventArgs e)         {             if (e.Row.RowType == DataControlRowType.DataRow)             {                 (e.Row.FindControl("lnkDelete") as LinkButton).OnClientClick = "return DeletegrdIndustrySplFiles('" + (rptAccordian.Items[e.Row.RowIndex].FindControl("GrdImageDetail")).ClientID + "','" + e.Row.RowIndex.ToString() + "');";             }         } //javascript to delete row from client side  function DeletegrdIndustrySplFiles(gridclientid, rowindex) {       ...

How to find main aspx page hidden control in child user control in c#

 (this.Parent.NamingContainer.FindControl("hfIsNeedToRebind") as HiddenField).Value

Get control name in Page_Load event after post back by any control

Add script -------------------- function __doPostBack(eventTarget, eventArgument)  { if  (!theForm.onsubmit || (theForm.onsubmit() ! =   false )) { theForm.__EVENTTARGET.value  =  eventTarget; theForm.__EVENTARGUMENT.value  =  eventArgument; theForm.submit();  }  } ---------------------- <input type= "hidden"  name= "__EVENTTARGET"  id= "__EVENTTARGET"  value= ""  /> <input type= "hidden"  name= "__EVENTARGUMENT"  id= "__EVENTARGUMENT"  value= ""  /> <select name="DropDownList1" onchange="javascript:setTimeout('__doPostBack(\'DropDownList1\',\'\')', 0)" id="DropDownList1">             <option value="1">abc</option>             <option value="2">xyz</option> </select> --------------------- private string getPostBackControlName() ...

calling webservice using json with parameters

//Aspx code ------- <input id="time" value="90:00" type="text" readonly="readonly" /> <input type="button" name="" value="Save" onclick="SaveTimerDetails();" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript">     //$(document).ready(function () {     function SaveTimerDetails() {         var time = document.getElementById('time').value;         var id = 1;         var vardata = "{ TimeID: " + id + ", TotalTime: '"+ time +"' }";         $.ajax({             type: "POST",             contentType: "application/json; charset=utf-8",         ...

Start and Stop Counter in javascript

//------------------Add these control in form  <input id="time" value="90:00" type="text" readonly="readonly" />         <input type="button" name="" value="Start" onmouseup="zxcStartTime('time',true);" />         <input type="button" name="" value="Stop" onmouseup="zxcStartTime('time',false);" /> //  //add these script <script type="text/javascript">     /*<![CDATA]*/     function zxcStartTime(id, srt) {         var obj = document.getElementById(id), ms = obj.value.split(/\W/);                 if (zxcStartTime[id]) {             clearTimeout(zxcStartTime[id].to);         }         if (srt && isFinite(ms[0]) ...