Archive for the ‘.Net’ Category
May 24, 2016
Requiredfieldvalidator not working onclientclick added in button.
Code : This code will not execute required field validator
<asp:Button ID="btnSubmit" runat="server" Text="Check"
OnClick="btnSubmit_Click"
OnClientClick="javascript:return confirm('Are you sure to Submit?')"
ValidationGroup="Submit" />
use Page_ClientValidate() predefined function to avoid issue.
Solution :
<asp:Button ID="btnSubmit" runat="server" Text="Check"
OnClick="btnSubmit_Click"
OnClientClick="return CheckToProceed();"
ValidationGroup="Submit" />
Javascript ::
function CheckToProceed() {
if (Page_ClientValidate()) {
return confirm('Are you sure to Submit?')
}
}
Reference : stackoverflow
Posted in .Net, C# | Tagged onclientclick, requiredfieldvalidator, requiredfieldvalidator not working onclientclick | Leave a Comment »
September 2, 2015
set Document mode standard/Edge in IE
Code :
Add meta tag in web page
<meta http-equiv=”X-UA-Compatible” content=”IE=edge” />
If you are using .net you can add this to the web.config
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
Posted in .Net, HTML | Tagged IE, Set Document mode standard/Edge in IE | Leave a Comment »
June 30, 2012
Convert a one date format to any other date format.
Date format must not be a regular Date format like ‘MM/dd/yyyy’. it can be a any format like ‘yyyyMMdd’
Coding :
public string DateFormatter(string Date,string RevFormat,string ReqFormat)
{
DateTime MyDateConverted = DateTime.ParseExact(Date, RevFormat, System.Globalization.CultureInfo.InvariantCulture);
string ReqDate = MyDateConverted.ToString(@ReqFormat);
return ReqDate;
}
Posted in .Net, C# | Tagged C#, Conver Date to any format from any other format, Date Convertion, Date Format | Leave a Comment »
July 18, 2011
We can create Numeric only text boxes in .Net Windows forms application with adding below code in Key Press Event.
Numeric only text boxes
private void txtBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != ‘.’)
{
e.Handled = true;
}
// only allow one decimal point
if (e.KeyChar == ‘.’ && (sender as TextBox).Text.IndexOf(‘.’) > -1)
{
e.Handled = true;
}
}
Integer only text boxes
private void txtBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) )
{
e.Handled = true;
}
}
Posted in WinForms | Tagged Integer only, Integer only TextBox Winforms, KeyPress event, Numeric Only, Numeric only TextBox Winforms, textbox, Validation, winforms | Leave a Comment »
December 10, 2010
Making Non-selectable options and indented option groups are pretty easy in select control. disabled the options is not a correct way to do, use optgroup option.
Making Non-selectable options :
<select >
<option >groups</option>
<optgroup label=”group1″> </optgroup>
<option> group 1 item 1</option>
<option> group 1 item 2</option>
<optgroup label=”group2″> </optgroup>
<option> group 2 item 1</option>
<option> group 2 item 2</option>
</select> |
Making indented option groups:
<select >
<option >groups</option>
<optgroup label=”group1″>
<option> group 1 item 1</option>
<option> group 1 item 2</option>
</optgroup>
<optgroup label=”group2″>
<option> group 2 item 1</option>
<option> group 2 item 2</option
>/optgroup>
</select> |
Posted in .Net, HTML | Tagged .Net, disabled, HTML, Non-selectable, optgroup, option group, select option, web forms | Leave a Comment »
September 13, 2010
In datagridview properties can not find AutoGenerateColumn property, but can find pragmatically.
Here can set false to hide columns, need to do before set the datasource.
Datagridview1.AutoGenerateColumn = false;
Datagridview1.DataSource = dt; |
Posted in .Net, WinForms | Tagged AutoGenerateColumn, datagridview, winforms | Leave a Comment »