Asp.net Grid View Javascript Validation

To Add Javasvript in Gridview For  Validation
Add Javascript Code in GridView RowDatabound Event
and call tha tfunction From Code

For GridView RowDatabound Add Javascript Code

if (e.Row.RowType == DataControlRowType.DataRow)
{

TextBox txtRate = (TextBox)e.Row.FindControl(“txtRate”);
txtRate.Attributes.Add(“onblur”, “return ValidateCalculation(‘”+txtRate.ClientID+”‘)”);
}

And in Aspx Page Add Following Javascript

<script type=”text/javascript”>
function ValidateCalculation(i)
{
alert(i);
alert(document.getElementById(i).value);
document.getElementById(i).focus();
}
</script>

Advertisement

Asp.net How to pass Value From Child Page to Parent Page

-For Parent Page Open Child Window

protected void Page_Load(object sender, EventArgs e)
{
string openWindow = @”window.open(‘Child.aspx’)”;
this.Button1.Attributes.Add(“onclick”, openWindow);
}

For Child Page

this.LinkButton1.Attributes.Add(“onclick”, “PassValues()”);

Write this Code for Javascript in Child Page

This code will pass value in Window.opener Form With Given Text Box

<script language=javascript>
function PassValues()
{
var txtValue = document.getElementById(“<%=TextBox1.ClientID%>”).value
window.opener.form1.txtUserName.value = txtValue;
window.close();
}
</script>

Asp.net Basic

Gridview Column date Format
DataFormatString=”{0:MM/dd/yyyy}”  HtmlEncode=”False”
—————————————————————————————
Date in “MM/dd/yyyy” Format
DateTime.Parse(dtTable.Rows[0][“StartedDate”].ToString()).ToString(“MM/dd/yyyy”);
—————————————————————————————
Check Query String is Null
if (!String.IsNullOrEmpty(Request.QueryString[“Id”]))
{
}
—————————————————————————————