get selected values form a checkboxlist c# asp.net web application
List
Achievement provides the only real pleasure in life
List
Posted by
SF
at
4:15 pm
0
comments
string path = HttpContext.Current.Server.MapPath("~/xxxxxxxx.txt");
if (!System.IO.File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = System.IO.File.CreateText(path))
{
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
sw.WriteLine("------------------------Some explanation of the purpose of this file-----------------------------");
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
sw.WriteLine("-------------------------------------------------------------------------------------------------------------------------------------");
}
}
using (StreamWriter sw = System.IO.File.AppendText(path))
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
sb.AppendLine("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
sb.AppendLine("WHEN: " + DateTime.Now.ToString());
sb.AppendLine("WHO: " + GetCurrentUser());
IPHostEntry host;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
sb.AppendLine("WHERE: " + ip.ToString());
break;
}
}
sb.AppendLine("WHAT: " + errorMsg);
sb.AppendLine();
sb.AppendLine();
sb.AppendLine();
sw.WriteLine(sb.ToString());
}
Posted by
SF
at
11:26 am
0
comments
find and run the following executable inside "%Windows\Microsoft.NET\[framework number]\[version number]\"
aspnet_regsql.exe
Posted by
SF
at
11:34 pm
0
comments
if the control you are looking for is a button:
((Button)e.CommandSource)
if the control you are looking for is a label:
((Label)e.CommandSource)
Posted by
SF
at
3:51 pm
0
comments
var width = $telerik.$(window).width() * 0.8;
var height = $telerik.$(window).height() * 0.95;
ExpWindow.setSize(width, height);
ExpWindow.center();
Posted by
SF
at
4:30 pm
0
comments
protected void
StiWebDesigner1_SaveReport(object sender,
Posted by
SF
at
3:20 pm
0
comments
protected void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e) { GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; switch (e.DetailTableView.Name) { GetDataByParentId(dataItem.GetDataKeyValue("Id").ToString()); } }
Posted by
SF
at
1:22 pm
0
comments
StringBuilder sb = new StringBuilder();
TextBox TextBox1 = new TextBox ();
TextBox1.ID = "TextBox1";
TextBox1.Text = "Hello World";
using (StringWriter sw = new StringWriter(sb))
{
using (HtmlTextWriter tw = new HtmlTextWriter(sw))
{
TextBox1.RenderControl(tw);
}
}
Posted by
SF
at
5:23 pm
0
comments
datetime value can be updated using the following query:
e.g. I want to replace the year value with '2012'
update table1
set date = convert(datetime,'2012'+'-'+convert(varchar(3),MONTH(date))+'-'+convert(varchar(3),DAY(date))+' '+ convert(varchar(12),convert(time,date))),
CompletedDate = convert(datetime,'2012'+'-'+convert(varchar(3),MONTH(CompletedDate))+'-'+convert(varchar(3),DAY(CompletedDate))+' '+ convert(varchar(12),convert(time,CompletedDate)))
where [condition]
Posted by
SF
at
11:07 am
0
comments
I can add a new column to an existing table no problem, but i had problem making it an autoincrement int primary key. After some research I found the solution: "Identity" keyword:
if not exists(SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'table1' AND COLUMN_NAME = 'ID')
begin
ALTER TABLE dbo.table1
add ID int identity not null
end
go
Posted by
SF
at
11:23 am
0
comments
I have this line to run a javascript from code behind:
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "sbScript", sbScript.ToString(), false);
This line is inside pageload event of the usercontrol that I used my my aspx page. The user control is used multiple times on the aspx page. The javascript is therefore called multiple times. However the script only works the first time.
The reason being is because the script name specified is always "sbScript" which has been assigned value when first run. The solution is to make sure the script name is set to different values everytime the line is executed.
Posted by
SF
at
2:08 pm
0
comments
I converted my website to a web application and upgraded .net framework from v3.5 to v4. I also setup a class library to host entity framework models for the web app to consume. At run time when the business logic calls the entity framework class library I got this error below.
Posted by
SF
at
8:24 am
0
comments
in my asp.net web application I got this problem when added a new class library into my solution and trying to build the solution:
"assembly generation failed referenced assembly does not have a strong name"
Apparently the solution is to go to the class Project properties: Solution Explorer > right click > properties, click on Signing tab, select "Sign the assembly", then browse the key shared among other projects within the same solution.
Posted by
SF
at
5:54 pm
0
comments
var labelText = $('#<%= lblabc.ClientID %>').html();
Posted by
SF
at
4:57 pm
0
comments
if ($('#isAgeSelected').is(':checked')){
//your code here
}
Posted by
SF
at
3:31 pm
0
comments
DATEPART(portion, datetimevalue)
the options for portion are:
Ms for Milliseconds
Yy for Year
Qq for Quarter of the Year
Mm for Month
Dy for the Day of the Year
Dd for Day of the Month
Wk for Week
Dw for the Day of the Week
Hh for Hour
Mi for Minute
Ss for Second
e.g.
select startdate,DATEPART(Hh,a.startdate)
this returns the hour of startdate
Posted by
SF
at
11:11 am
0
comments
if you want something like "22/11/2012 15:00" then use
columns.Bound(o => o.MyDateTimeValue).Format("{0:dd/MM/yyyy HH:mm}").Width(120);
if you want something like "22/11/2012 3:00 PM" then use
columns.Bound(o => o.MyDateTimeValue).Format("{0:dd/MM/yyyy hh:mm tt}").Width(120);
Posted by
SF
at
1:56 pm
0
comments
i keep forgetting this simple solution:
char(13)
now I save it here so that I never forget again
Posted by
SF
at
6:00 pm
0
comments