All ASP.Net Control
------------------------------------------------------------------------------------------------------------------------
// !st Method
<asp:Button ID="btn" runat="server" Text="some really breally long text that I want to wrap" style="white-space:normal; width:150px;" />
//Second Method
In head section of aspx page write below code
<style type="text/css">
.wrap { white-space: normal; width: 100px; }
</style>
then call the above method in html body part.
<asp:Button ID="btn" runat="server" Text="some really breally long text that I want to wrap" CssClass="wrap" />
//Third method
In aspx html body part.
<asp:Button ID="btnText" runat="server" CssClass="wrap" />
btnText.Text = "This is first button \n This is second button.";
Reset Drop down list in Asp.Net C#
//In .aspx page
<br />
<div>
<asp:dropdownlist id="ddlcountry" runat="server">
<asp:listitem text="Select Country" value="Select Country"></asp:listitem>
<asp:listitem text="India" value="India"></asp:listitem>
</asp:dropdownlist>
<br />
<br />
<asp:button id="btnreset" onclick="btnreset_Click" runat="server" text="Reset">
</asp:button>
</div>
// In .cs code behind part
protected void btnreset_Click(object sender, EventArgs e)
{
ddlcountry.SelectedIndex = -1;
}
Custom Validation
function doPhoneValidate(source, args) {
args.IsValid = false;
if (document.getElementById('<% =txtphone1.ClientID %>').value.length > 0 && document.getElementById('<% =txtphone2.ClientID %>').value.length > 0 && document.getElementById('<% =txtphone3.ClientID %>').value.length > 0) {
args.IsValid = true;
}
}
<tr>
<td align="left">
Phone<font color="red">*</font>:
</td>
<td align="left">
<asp:TextBox ID="txtphone1" runat="server" class="number" placeholder="Country" MaxLength="10"
Width="40px"></asp:TextBox>
<asp:TextBox ID="txtphone2" runat="server" class="number" placeholder="Area" MaxLength="10"
Width="40px"></asp:TextBox>
<asp:TextBox ID="txtphone3" runat="server" class="number" placeholder="Number" MaxLength="20"
Width="110px"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ForeColor="Red"
ErrorMessage="Required!" ControlToValidate="txtphone1" ClientValidationFunction="doPhoneValidate"
ValidateEmptyText="true"></asp:CustomValidator>
</td>
</tr>
.....................................................................................................................................................
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
void ValidateBtn_OnClick(object sender, EventArgs e)
{
// Display whether the page passed validation.
if (Page.IsValid)
{
Message.Text = "Page is valid.";
}
else
{
Message.Text = "Page is not valid!";
}
}
void ServerValidation(object source, ServerValidateEventArgs args)
{
try
{
// Test whether the value entered into the text box is even.
int i = int.Parse(args.Value);
args.IsValid = ((i%2) == 0);
}
catch(Exception ex)
{
args.IsValid = false;
}
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<h3>CustomValidator ServerValidate Example</h3>
<asp:Label id="Message"
Text="Enter an even number:"
Font-Name="Verdana"
Font-Size="10pt"
runat="server"/>
<p>
<asp:TextBox id="Text1"
runat="server" />
<asp:CustomValidator id="CustomValidator1"
ControlToValidate="Text1"
ClientValidationFunction="ClientValidate"
OnServerValidate="ServerValidation"
Display="Static"
ErrorMessage="Not an even number!"
ForeColor="green"
Font-Name="verdana"
Font-Size="10pt"
runat="server"/>
<p>
<asp:Button id="Button1"
Text="Validate"
OnClick="ValidateBtn_OnClick"
runat="server"/>
</form>
</body>
</html>
<script language="javascript">
function ClientValidate(source, arguments)
{
if (arguments.Value % 2 == 0 ){
arguments.IsValid = true;
} else {
arguments.IsValid = false;
}
}
</script>
------------------------------------------------------------------------------------------------------------------------
1.
Check
the check box list from database find value. 111014
string
strBrandList1 = drfrm1["ex23"].ToString();
string[]
varBrandList1 = strBrandList1.Split('^');
foreach
(string frmbrndLst1 in
varBrandList1)
{
foreach
(ListItem lst1 in
ChList1.Items)
{
if (frmbrndLst1 == lst1.Text)
{
lst1.Selected = true;
break;
}
}
}
2.
Select checked list form check box list for
insert
string
selcetdProd1 = string.Empty;
foreach
(ListItem lst1 in
ChList1.Items)
{
if
(lst1.Selected)
{
if
(selcetdProd1 == "" ||
selcetdProd1 == null)
selcetdProd1 = lst1.Text;
else
selcetdProd1 = selcetdProd1
+ "^" + lst1.Text;
}
}
3.
Select
the dropdown from database dynamic value (With the help of findByValue)
string
country = (e.Row.FindControl("lblCountry")
as Label).Text;
ddlCountries.Items.FindByValue(country).Selected = true;
4.
Disable
the radio button list dynamically with position wise.
if (dr["enhanced"].ToString().ToLower().Trim()
== "yes")
{
chkShowGuide.Items[0].Enabled = false;
chkShowGuide.Text = "Enhanced Entry";
chkShowGuidechangeBox();
}
5.
Get
Value form Data Table
foreach (DataRow
dr3 in dtFormStatus.Rows)
{
if
(Convert.ToString(dr1["exid"]) == Convert.ToString(dr3["exid"]) && Convert.ToString(dtExhiDetails.Columns[dr3["formid"].ToString()].ColumnName.ToString())
== Convert.ToString(dr3["formid"]))
{
if
(Convert.ToString(dr3["status"]) == "S")
strcolor = "images/s_img.png";
else
if (Convert.ToString(dr3["status"]) == "D")
strcolor = "images/d_img.png";
else
if (Convert.ToString(dr3["status"]) == "N")
strcolor = "images/n_img.png";
strformTable.Append("<td align='center'><a style='color:black;'
href='Viewform" + Convert.ToString(dr3["formid"]) + ".aspx?exid="
+ Convert.ToString(dr1["exid"]) + "&frmid="
+ Convert.ToString(dr3["formid"]) + "&height=600&width=830&modal=true'class='thickbox'><img
alt='' src='" + strcolor + "' /></a></td>");
}
}
1.
Note
(270914).
Two same id in gridview template is right
but not in the page. it's case sensetive. even id=lblname and lblNAME is also
not right in main page.
2.
In master page code behind cs page insert the
below code. Then there is no need to give the title in every page.
Note:- But that master page must
be attached with all page in the website.
Page.Title =
"CarFest North 2014 :: Control Panel";
3.
Get the
ip address of login system of any client
Request.ServerVariables["REMOTE_ADDR"];
4.
Multiple
query string in asp.net
Response.Redirect("second.aspx?name=" + TextBox1.Text +
"&address=" + TextBox2.Text + "&email="+
TextBox3.Text);}
5.
Bind
table dynamic
<asp:Table ID="tblSearch" runat="server"></asp:Table>
TableRow oRow = new TableRow();
TableCell oCell = new TableCell();
Label
olb = new Label();
olb.Text = "<a href=Default.aspx?refer=" + link_href +
">" + link_heading + "</a>";
oCell.Controls.Add(olb);
oRow.Cells.Add(oCell);
tblSearch.Rows.Add(oRow);
rowCount = rowCount + 1;
6.
reset the
drop down list and check drop down list is selected or not.
ddl.SelectedIndex=-1;
ddlGalleryName.SelectedIndex
= 0;
7.
Execute
another page in another page. 290914
Server.Execute("Default.aspx");
8.
Execute Here
Postbackurl is used in gridview. Because when user click on edit button it'll
go bottom of the page where A1 anchor
is availave that's why there he can update the form.
<asp:TemplateField HeaderText="EDIT">
<ItemTemplate>
<asp:Button ID="btnEdit"
PostBackUrl="#A1" runat="server" Text="Edit"
CausesValidation="False"
CommandName="select"
Height="20px" />
</ItemTemplate>
</asp:TemplateField>
<a name="A1"></a>
.... bottom of the page anchor tags
9.
Hw to
link the usercontrol in any html form.290914
<%@ Register Src="LeftNavCtrl.ascx" TagName="LeftNavCtrl"
TagPrefix="uc1" %>
1 Dynamic set attribute on the textbox control in code
behind. 061114
txtCompanyProfile.Attributes.Add("onkeyup",
"LimitSize();");
txtCompanyProfile.Attributes.Add("onblur",
"limitText();")
Dynamic set attribute to generate excel on
click
<asp:LinkButton
ID="LinkButton1"
runat="server">Click
here</asp:LinkButton> to
download excel reports
LinkButton1.OnClientClick
= "javascript:OpenPage('Exhibitor_AllForms_Status_download.aspx');return
false;";
1 hw can u handle when no one radio button is selected and we want to
pass selected value. alternative.
string
abc = "";
if
(RadioButtonList3.SelectedValue=="NO"||RadioButtonList3.SelectedValue=="Yes")
{
abc = Convert.ToString(RadioButtonList3.SelectedItem.Text);
}
Manage Dynamic binding with
anchor tag
lblPre.Text
= "Previous form : <a href=form" + arInfo[count1 - 1] +
".aspx>" + PrevFormaname + "</a>";
Send value to next page and retrieve on that page.
<form
action="exhibitorloginzone.aspx"
method="post" name="logoff">
</form>
</BODY>
string
email = Request.Form["emailed"];
string
stand = Request.Form["stands"];
string
status = Request.Form["status"];
Set Session Time out and error
page on off
<System.web>
<sessionState mode="InProc"
timeout="30" />
<customErrors mode="On" defaultRedirect="ServerResponse.aspx">
</customErrors>
</System.Web>
PDF opener.
if
(drCont["cType"].ToString() == "Content")
Contents.InnerHtml =
drCont["contents"].ToString();
else
if (drCont["cType"].ToString()
== "PDF")
Contents.InnerHtml = "<embed
src='https://onlineexhibitormanual.com/Abilities13/document/" +
drCont["UploadDoc"].ToString() + "' width='100%' height='700'
type='application/pdf'></embed>";
else
Contents.InnerHtml =
drCont["contents"].ToString();
Dynamic bind date with anchor tag for send mail like mailto:
//Code for Exhibitor details
SqlCommand
sqlExhi = new SqlCommand("Select fname+' '+lname as
name,email,username,password from tblexRegInfo,tblexhibitor where
tblexhibitor.eventid='" + Session["eventid"]
+ "' and tblexhibitor.eventid=tblexRegInfo.eventid
and tblexhibitor.exid='" + Session["exid"]
+ "' and tblexhibitor.exid=tblexRegInfo.exid
", Conn);
Conn.Open();
SqlDataReader
dr = sqlExhi.ExecuteReader();
if
(dr.Read())
{
string textm =
"?subject=Middle East Stone Show 2015 - Share
with a Colleague&body=Dear colleague,%0D%0A%0D%0AWhile working on
completing this year’s Big 5 online exhibitor manual, I found the following
which is relevant for you to see, and benefit from.%0D%0A%0D%0A
https://onlineexhibitormanual.com/MEStone15/ExhibitorLoginZone.aspx
%0D%0A%0D%0AUsername and login details sent once again here enable you to
access the manual, view information and packages, plus submit orders for both
free and paid exhibitor benefits.%0D%0A%0D%0AUsername: " + Convert.ToString(dr["username"])
+ "%0D%0A%0D%0APassword: " + Convert.ToString(dr["password"])
+ "%0D%0A%0D%0ASincerely,%0D%0A%0D%0A"
+ Convert.ToString(dr["name"]);
lblemail.Text = "<a href='mailto:" + Convert.ToString(dr["email"])
+ textm + "' class='btngoback'
style='background-image:none; margin-right:24px;'>Share with a
Colleague</a>";
}
Conn.Close();
dr.Close();
Asp.Net Validation
---------------------------------------------------------------------------------------------
1.
Set
message summery none for validation summery validation control with style.
<asp:ValidationSummary ID="vali"
runat="server"
ShowMessageBox="false"
ShowSummary="true"
DisplayMode="BulletList"
HeaderText="The
form cannot be submitted. Please scroll up and fill in the missing
fields."
SetFocusOnError="true"
Display="Dynamic"
ForeColor="Red"
CssClass="validation_summary_as_bulletlist"
Font-Italic="true"
/>
<style type="text/css">
.validation_summary_as_bulletlist ul
{
display: none;
}
</style>
2.
Restrict
the special character in textbox with regular expression.
<asp:TextBox ID="txtHeading" runat="server" MaxLength="300"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExTextBox17preTextBox1alidator14" runat="server"
ControlToValidate="txtHeading" ValidationExpression="[^<>%;]+" ErrorMessage="Special symbols(<>%;) are not allowed."
Display="Dynamic" SetFocusOnError="True"></asp:RegularExpressionValidator>
3.
Email-Id
Validation with the help of regular expression validation.(250914)
<asp:RequiredFieldValidator
ID="RequiredFieldValidator5" ControlToValidate="txtEmail"
runat="server" ErrorMessage="Please enter
email">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server"
ErrorMessage="Please Enter Valid Email Address"
ControlToValidate="txtEmail" Display="Dynamic"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
4.
To show
the validation summary if error occur. (250914)
<tr>
<td colspan="4">
<asp:ValidationSummary ID="ValidationSummary1"
HeaderText="The following fields are required"
runat="server" ShowMessageBox="True"
ShowSummary="False" Font-Size="XX-Small"
Width="200px" />
</td>
</tr>
5.
To
Validate the special symbol like "#,$,%" etc.... (250914)
<asp:TextBox ID="txttitle" runat="server"
Width="300px" MaxLength="200"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ControlToValidate="txttitle"
ErrorMessage="Enter the
title."
SetFocusOnError="True">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExTextBox17preTextBox1alidator14" runat="server"
ControlToValidate="txttitle"
ValidationExpression="[^<>%;]+" ErrorMessage="Special
symbols(<>%;) are not allowed."
Display="Dynamic"
SetFocusOnError="True"></asp:RegularExpressionValidator>
6.
Validation
for image uploads with the help of regular expression. (250914)
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="UploadImage1"
ValidationExpression=".*\.(PDF|GIF|JPG|JPEG|jpg|gif|jpeg|pdf)"
Display="Dynamic"
ErrorMessage="Please upload jpg/gif/pdf files
only"></asp:RegularExpressionValidator>
<asp:FileUpload ID="UploadImage1"
runat="server" />
7.
enableclientscript="False"
property for all validator in asp.net used to enable or disable with true false
property , false means validation will work after post back. by default it is
true. Means client side validation with new version browser. (250914)
<asp:requiredfieldvalidator
id="TextBoxRequiredValidator"
controltovalidate="NumberTextBox"
enableclientscript="False" display="Dynamic"
errormessage="Please enter a value." text="*"
runat="server"/>
8.
Date
cannot be selected form today and also with static value with the help of ajax
calender extender and Compare validaotr
of asp.net control. For one textbox (250914)
<asp:TextBox ID="TextBox1" runat="server"
MaxLength="100" Width="200px"></asp:TextBox>
<asp:Image
ID="Image1" runat="server"
ImageUrl="~/images/show-calendar.gif" />
<cc1:CalendarExtender
ID="CalendarExtender1" runat="server"
TargetControlID="TextBox1"
Format="dd-MM-yyyy"
PopupButtonID="Image1">
</cc1:CalendarExtender>
<asp:CompareValidator ID="CompareValidator1"
runat="server" Type="Date"
Operator="GreaterThanEqual"
ControlToValidate="TextBox1" Display="Dynamic"
SetFocusOnError="True" ErrorMessage="Please enter date after
17th of June,
2014.">
</asp:CompareValidator>
//.cs page on page load
// static value
CompareValidator1.ValueToCompare =
Convert.ToString("18-06-2014");
// for current date
CompareValidator1.ValueToCompare = DateTime.Now.ToString("dd-MM-yyyy");
NOTe:-
formate must be same in calender extender and compair validator.
9.
Restrict
the special character in textbox with regular expression. (151114)
<asp:RegularExpressionValidator
ID="RegularExTextBox17preTextBox1alidator14"
runat="server" ControlToValidate="TextTitle"
ValidationExpression="[^<>%;]+" ErrorMessage="Special
symbols(<>%;) are not allowed."
Display="Dynamic"
SetFocusOnError="True"></asp:RegularExpressionValidator>
1 Regular
expression for upload. (191114)
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="UploadImage1"
ValidationExpression="^.*\.(jpg|JPG|jpeg|JPEG|doc|DOC|docx|DOCX|xls|XLS|xlsx|XLSX|pdf|PDF)$"
Display="Dynamic"
ErrorMessage="Please
upload doc/pdf files only"></asp:RegularExpressionValidator>
1 Validate Special character
<asp:RegularExpressionValidator
ID="RegularExpressionValidator3" runat="server"
ControlToValidate="txtcompany"
ValidationExpression="[^<>%;]+"
ErrorMessage="Special symbols(<>%;) are not allowed."
Display="Dynamic"
SetFocusOnError="True"></asp:RegularExpressionValidator>
Wrap Button in Asp.Net C#
// !st Method
<asp:Button ID="btn" runat="server" Text="some really breally long text that I want to wrap" style="white-space:normal; width:150px;" />
//Second Method
In head section of aspx page write below code
<style type="text/css">
.wrap { white-space: normal; width: 100px; }
</style>
then call the above method in html body part.
<asp:Button ID="btn" runat="server" Text="some really breally long text that I want to wrap" CssClass="wrap" />
//Third method
In aspx html body part.
<asp:Button ID="btnText" runat="server" CssClass="wrap" />
btnText.Text = "This is first button \n This is second button.";
Reset Drop down list in Asp.Net C#
//In .aspx page
<br />
<div>
<asp:dropdownlist id="ddlcountry" runat="server">
<asp:listitem text="Select Country" value="Select Country"></asp:listitem>
<asp:listitem text="India" value="India"></asp:listitem>
</asp:dropdownlist>
<br />
<br />
<asp:button id="btnreset" onclick="btnreset_Click" runat="server" text="Reset">
</asp:button>
</div>
// In .cs code behind part
protected void btnreset_Click(object sender, EventArgs e)
{
ddlcountry.SelectedIndex = -1;
}
Custom Validation
function doPhoneValidate(source, args) {
args.IsValid = false;
if (document.getElementById('<% =txtphone1.ClientID %>').value.length > 0 && document.getElementById('<% =txtphone2.ClientID %>').value.length > 0 && document.getElementById('<% =txtphone3.ClientID %>').value.length > 0) {
args.IsValid = true;
}
}
<tr>
<td align="left">
Phone<font color="red">*</font>:
</td>
<td align="left">
<asp:TextBox ID="txtphone1" runat="server" class="number" placeholder="Country" MaxLength="10"
Width="40px"></asp:TextBox>
<asp:TextBox ID="txtphone2" runat="server" class="number" placeholder="Area" MaxLength="10"
Width="40px"></asp:TextBox>
<asp:TextBox ID="txtphone3" runat="server" class="number" placeholder="Number" MaxLength="20"
Width="110px"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ForeColor="Red"
ErrorMessage="Required!" ControlToValidate="txtphone1" ClientValidationFunction="doPhoneValidate"
ValidateEmptyText="true"></asp:CustomValidator>
</td>
</tr>
.....................................................................................................................................................
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<head>
<script runat="server">
void ValidateBtn_OnClick(object sender, EventArgs e)
{
// Display whether the page passed validation.
if (Page.IsValid)
{
Message.Text = "Page is valid.";
}
else
{
Message.Text = "Page is not valid!";
}
}
void ServerValidation(object source, ServerValidateEventArgs args)
{
try
{
// Test whether the value entered into the text box is even.
int i = int.Parse(args.Value);
args.IsValid = ((i%2) == 0);
}
catch(Exception ex)
{
args.IsValid = false;
}
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<h3>CustomValidator ServerValidate Example</h3>
<asp:Label id="Message"
Text="Enter an even number:"
Font-Name="Verdana"
Font-Size="10pt"
runat="server"/>
<p>
<asp:TextBox id="Text1"
runat="server" />
<asp:CustomValidator id="CustomValidator1"
ControlToValidate="Text1"
ClientValidationFunction="ClientValidate"
OnServerValidate="ServerValidation"
Display="Static"
ErrorMessage="Not an even number!"
ForeColor="green"
Font-Name="verdana"
Font-Size="10pt"
runat="server"/>
<p>
<asp:Button id="Button1"
Text="Validate"
OnClick="ValidateBtn_OnClick"
runat="server"/>
</form>
</body>
</html>
<script language="javascript">
function ClientValidate(source, arguments)
{
if (arguments.Value % 2 == 0 ){
arguments.IsValid = true;
} else {
arguments.IsValid = false;
}
}
</script>
Asp.Net C# Code
---------------------------------------------------------------------------------------------
1.
Generate
random no for captcha in c# 290914
protected
void Page_Load(object
sender, EventArgs e)
{
lblshow.Text = GenerateRandomCode();
}
private string GenerateRandomCode()
{
string
s = "";
for (int i = 0; i < 6; i++)
s = String.Concat(s,
this.randow.Next(10).ToString());
return
s;
}
2.
The code within the finally block is always
run - exception or no exception. It's a
good place if you need to close file references or dispose objects you won't
need anymore.
3.
By
default namespace is public. By default class is internal. By default method is
private.
4.
Some
example of C# function.
string ch1 = string.Empty;
string
pname17 = string.Empty;
foreach
(ListItem ls in
RadioButtonList1.Items)
{
if
(ls.Selected)
ch1 += ls.Text + "^";
}
ch1 = ch1.TrimEnd('^');
if (!string.IsNullOrEmpty(ch1.ToString()))
{
if
(ch1.Contains("^"))
ch1.Replace("^", "<b><font
color='red'>^</font></b>");
pname17 = "<tr><td
width='30%'>THE CONTRACTOR IS RESPONSIBLE FOR</td><td
width='70%'>" + ch1.Replace('^',',') + "</td></tr>";
}
5.
Here
Postbackurl is used in gridview. Because when user click on edit button it'll
go bottom of the page where A1 anchor
is availave that's why there he can update the form. 151114
<asp:TemplateField HeaderText="EDIT">
<ItemTemplate>
<asp:Button ID="btnEdit"
PostBackUrl="#A1" runat="server" Text="Edit"
CausesValidation="False"
CommandName="select"
Height="20px" />
</ItemTemplate>
</asp:TemplateField>
<a name="A1"></a>
.... bottom of the page anchor tags
6.
Hw to
link the user control in any html form.
<%@
Register Src="LeftNavCtrl.ascx"
TagName="LeftNavCtrl" TagPrefix="uc1" %>
<td width="20%" style="background-image:
url('images/navi_bg.jpg'); background-position: top; background-repeat:
no-repeat;" valign="top">
<uc1:LeftNavCtrl ID="LeftNavCtrl1" runat="server" /> </td>
7.
Query
String dynamic and static
Response.Redirect("Default2.aspx?UserId="+txtUserId.Text+"&UserName="+txtUserName.Text);
NavigateUrl="~/Image.aspx?ImageID=1&ImageName=Elephant"
-- Get more than one query string
lblUserId.Text = Request.QueryString["UserId"];
lblUserName.Text = Request.QueryString["UserName"];
8.
find
previous page in asp.net
string
prevurl = Request.UrlReferrer.ToString();
9.
Max
two decimal formate or u can set as u wish now with the help of below code
<%=
netamt.ToString("0.00")%> in any string variable u can attach .ToString("Formate required")
1 Find
the id of master page control in child Page\
this.Master.FindControl("rightsection_ep").Visible = false;
1 Define
decimal point with string vaule like totamt string;
NetEqptotal
= Math.Round(totamt, 2);
1 how
to bind dynamic value in strin variable and change its color so nice.
lblSaveDraft.Text = "<br><br>This form has been saved as a
draft and needs to be filled in completely.<br>
The
last date to fill this form is <font color='#FF0000'><b>" + deadlinedate + "</b></font><br><br>";
1 Weight
the content of file
if (((Convert.ToDecimal(Upload1.PostedFile.ContentLength)
/ 1024) / 1024) > 7)
{
lblOutput1.Text = "Documents cannot exceed 7MB in size";
}
1 Make
use of anchor as Images
<a
href="logoff.aspx"><img src="images/logout_btn.gif" border="0" alt="Logoff"
/></a>
1 how
to bind a variable in design part take it protected.
<td class="speaker_new">
<%=strSpeakerProfiles%>
</td>
protected string strSpeakerNames =
string.Empty;
1 String
with like statement like dynamic query
SqlCommand
sql1 = new SqlCommand("select a.exid,ROW_NUMBER() over(order by
a.company_name) AS SNo, c.username,
c.password,c.security_code,
a.company_name,a.BannerName,a.nickname,a.DmgUniqueId,b.Hall,b.StandNo,b.Width,b.Length,
b.fld4,b.SpaceCell,a.prefix,a.fName,a.lName,a.title,a.address,a.aptname,a.aptemail,a.telephone,a.email,a.city,
a.state,a.zip,a.country,a.field3,a.entry_date
from tblexreginfo a join tbl_insert_standdetails b on
a.exId=b.ExhibitorId
and a.eventId=b.eventid and a.eventId='" +
Session["eventid"] + "' join tblExhibitor c on
a.exId=c.exid
and a.eventId=c.eventid and c.eventid='" +
Session["eventid"] + "' where a.confirm_status='yes' and
c.username
like 'U49C%' order by a.company_name", Conn1);
1 Call
Java script function in code behind c# page. 241114
protected void chkShowGuide_SelectedIndexChanged(object sender, EventArgs
e)
{
if
(chkShowGuide.SelectedValue.ToString() == "Standard
Entry")
{
txtCompanyProfile.Attributes.Add("onkeyup", "LimitSize();");
txtCompanyProfile.Attributes.Add("onblur", "limitText();");
uploadLogo.Visible = false;
uploadLogotext.Visible = false;
Button1.Enabled = false;
}
}
1 Replace
special character form string with the help of Rejex.
string
Cmpny = Regex.Replace(company_name, "[^a-zA-Z0-9_]+", "");
1 Add
dynamically attribute in item.
foreach (GridViewRow row in
ExtraBadgesGrid.Rows)
{
LinkButton
lb = (LinkButton)ExtraBadgesGrid.Rows[row.RowIndex].Cells[0].FindControl("lblDelete");
lb.Attributes.Add("onclick", "if(!confirm('The
badge willl be deleted permanently. Are you sure you wish to delete the
badge?'))return false;");
}
2 Calculate Time //code for form close
TimeSpan
difference = Convert.ToDateTime(formClosingDate).Subtract(DateTime.Now);
if
(difference.Days < 0)
{
btnSave.Enabled = false;
btnDraft.Enabled = false;
}
2 Replace
query in c#
<%=dr1["ex7"].ToString().Replace('^',
',')%>
2 String
understanding
updatestand
= stand + ";" + dr["stands"].ToString();
if
(updatestand != "")
{
string
newupdatedstands = string.Empty;
string[]
oldstand = updatestand.Split(';');
string[]
newstand = oldstand.Distinct().ToArray();
for
(int i = 0; i < newstand.Length; i++)
{
if (string.IsNullOrEmpty(newupdatedstands))
newupdatedstands =
newstand[i].ToString();
else
newupdatedstands += ";" + newstand[i].ToString();
}
stand = newupdatedstands;
}
else
stand = updatestand;
2 Round
function in C#
netamt.Text = Convert.ToString(Math.Round(Convert.ToDecimal(totamt), 2));
Pass Multiple Mail Id In Asp.Net C#
adminemail = "amod@gmail.com,sharman@gmail.com";
Calculate time stamps in C#.Net
string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
Pass Multiple Mail Id In Asp.Net C#
adminemail = "amod@gmail.com,sharman@gmail.com";
Calculate time stamps in C#.Net
string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
No comments:
Post a Comment