Validate Checkbox and Checkboxlist in easy way
Hi Good Evening Techies.
Validation Control for Checkbox and Checkboxlist
Alternatively Download the file here skmValidators.rar
Hi Good Evening Techies.
<ajax:ScriptManager ID="ScriptManager1" runat="server"> </ajax:ScriptManager>
<asp:HyperLink ID="Hyperlink1" runat="server" Text="Session Mode" NavigateUrl="~/Description.aspx"></asp:HyperLink> <ajaxToolkit:HoverMenuExtender ID="hme2" runat="Server" TargetControlID="Hyperlink1" PopupControlID="Panel1" PopupPosition="Center" OffsetX="-25" OffsetY="15" />
<asp:Panel ID="Panel1" runat="server" Width="600px">
<asp:DataList ID="Dtl_Unit" CellPadding="1" CellSpacing="1"
ShowHeader="False" BorderWidth="0px"
runat="server" DataKeyField="ServicesSubId" DataSourceID="Sqd_Unit"
RepeatColumns="5">
<ItemTemplate>
<table border="0">
<tr>
<td>
<asp:HyperLink ID="Hyperlink2" runat="server"
NavigateUrl='<%#"Description.aspx?SId="+Eval("sessionmodeID") %>'
Text='<%#Eval("sessionmodeName")%>'></asp:HyperLink>
</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle BorderWidth="0px" />
</asp:DataList>
<asp:SqlDataSource ID="Sqd_Unit" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [sessionmodeID], [sessionmodeName] FROM
[SessionTable]">
</asp:SqlDataSource>
</asp:Panel>
When i faced this issue
if(!IsPostback)
{
//Bind the Gridview Databind
}
// here getting the 15 Minutes, if you want the time difference you use it here..ie: to // update the your page at regular intervals.
TimeSpan onlineSpan = new TimeSpan(0,15,0);
// here i minus the 15 Minutes from the Current Datetime and pass it as a parameter
DateTime compareTime = DateTime.Now.Subtract(onlineSpan);
using (SqlCommand cmd = new SqlCommand("SELECT users.username from users where users.LastActivityDate > @CompareDate ", con))
{
cmd.Parameters.Add("@CompareDate", SqlDbType.DateTime).Value = compareTime;
using(SqlDataAdapter adap = new SqlDataAdapter())
{
adap.SelectCommand = cmd;
}
}
DataTable dt = new DataTable();
adap.Fill(dt);
OnlineuserList_GridView.DataSource = dt;
OnlineuserList_GridView.DataBind();
Good Day to All.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns ="True" OnRowDataBound="GridView1_RowDataBound"> <Columns > <asp:TemplateField > <ItemTemplate > <table > <tr> <td> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </td> <br /> <td> <asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder> </td> <br /> <td> <asp:PlaceHolder ID="PlaceHolder3" runat="server"></asp:PlaceHolder> </td> </tr> </table> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:Button ID="Button1" runat="server" Text="Get Value" OnClick="Button1_Click" />
private void BindArraylist()
{
List<string> bindG = new List<string>() ;
bindG .Add ("Mani");
bindG .Add ("Shivaram");
bindG .Add ("Gopi");
bindG.Add ("Venu");
GridView1 .DataSource = bindG ;
GridView1 .DataBind ();
}
//page_OnLoad
if (!Page.IsPostBack)
{
BindArraylist();
}
//On Row databound we are creation a dynamic dropdownlist, by adding some items and added to the Placholder Container
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
PlaceHolder p1 = new PlaceHolder();
PlaceHolder p2 = new PlaceHolder();
PlaceHolder p3 = new PlaceHolder();
p1 = (PlaceHolder)e.Row.FindControl("PlaceHolder1");
p2 = (PlaceHolder)e.Row.FindControl("PlaceHolder2");
p3 = (PlaceHolder)e.Row.FindControl("PlaceHolder3");
DropDownList d1 = new DropDownList();
DropDownList d2 = new DropDownList();
DropDownList d3 = new DropDownList();
d1.ID = "d1";
d1.Items.Add("123");
d1.Items.Add("00");
d1.Items.Add("dfgdf");
d2.ID = "d2";
d2.Items.Add("34f");
d2.Items.Add("h456");
d2.Items.Add("ngfy3e35");
d3.ID = "d3";
d3.Items.Add("3478");
d3.Items.Add("0fghdj0");
d3.Items.Add("2d43g5gh5");
p1.Controls.Add(d1);
p2.Controls.Add(d2);
p3.Controls.Add(d3);
}
}protected void Button1_Click(object sender, EventArgs e)
{
BindArraylist();
foreach (GridViewRow row in GridView1.Rows)
{
DropDownList d1 = new DropDownList();
DropDownList d2 = new DropDownList();
DropDownList d3 = new DropDownList();
d1 = (DropDownList)row.FindControl("d1");
d2 = (DropDownList)row.FindControl("d2");
d3 = (DropDownList)row.FindControl("d3");
//txtValues.Add(d1.SelectedIndex.ToString());
Response.Write(d1.SelectedValue.ToString() + "-" + d2.SelectedValue.ToString() + "-" + d3.SelectedValue.ToString());
}
}
When i was worked with Ajax with timer Control i have the task ie: updating the some control inside the UpdatePanel ie: I am refreshing or call the method at regular intervals. That time i got this error
Sys.WebForms.PageRequestManagerServerErrorException ... 404 not found
This error occurs only when the page is idle for 1 min or more than 1 min, so i googled to get the solution for this issue. there is number of solution available according the problem and at which situation you are using.
< asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="false" />
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
//add line to the file
AddToFile("Make starting service");
//ad 1: handle Elapsed event
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
//ad 2: set interval to 1 minute (= 60,000 milliseconds)
timer.Interval = 60000;
//ad 3: enabling the timer
timer.Enabled = true;
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
timer.Enabled = false;
AddToFile("Make stopping service");
}
private void AddToFile(string contents)
{
//set up a filestream
FileStream fs = new FileStream(@"c:\timelog.txt", FileMode.OpenOrCreate, FileAccess.Write);
//set up a streamwriter for adding text
StreamWriter sw = new StreamWriter(fs);
//find the end of the underlying filestream
sw.BaseStream.Seek(0, SeekOrigin.End);
//add the text
sw.WriteLine(contents);
//add the text to the underlying filestream
sw.Flush();
//close the writer
sw.Close();
}
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
AddToFile("Make Another entry");
}<add key="Set_Css" value="App_Themes/Default/Css1.css,App_Themes/Default/Css2.css"/> <add key="Set_Javascript" value="Javascripts/Js1.js,Javascripts/Js2.js, http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"/>
<link type="text/css"
rel="Stylesheet"
href="HttpCombiner.ashx?s=Set_Css&t=text/css&v=1" />
<script
type="text/javascript"
src="HttpCombiner.ashx?s=Set_Javascript&t=type/javascript&v=2" >
</script>Good Evening to All.
Here I am going to cover how to compress the .aspx pages.
so there are no.of ways to compress the pages in asp.net
1) using IIS.
2) using Code ie: through HTTPCompress.dll i got the source code from codeproject.com.
so i am going to share with you.
There are two type of Compression ie: Deflate , GZIP. here i am going to use GZIP compression to compress the asp.net pages.
First Place the DLL file ie::HTTPCompress.dll to the Bin folder of your project.
Then you have to include some tag on web.config file
<configsections>
<sectiongroup name="Flanders">
<section name="HttpCompress" type="Flanders.Library.Modules.HttpCompress.Configuration, HttpCompress">
</section>
</sectiongroup>
<flanders>
<httpcompress compressiontype="GZip">
<excludedpaths>
<add path="NoCompression.aspx">
</add>
<excludedmimetypes>
<add mime="image/jpeg">
</add>
</excludedmimetypes></excludedpaths>
</httpcompress>
</flanders></configsections>Here i am using GZiP Compression technique. there are two more inner Tags ie: ExcludePaths, ExcludeMimeTypes.
<excludedmimetypes> <add mime="image/jpeg"> <add mime="image/jpg"> <add mime="image/png"> <add mime="image/gif"> </add> </add> </add> </add> </excludedmimetypes>
<httpmodules> <add> name="HttpCompressModule" type="Flanders.Library.Modules.HttpCompress.HttpModule,HttpCompress"/> </add> </httpmodules>Download Source Code
Some members asked this question on forums. Here is the Solution to overcome this issue.
When i am going to compress the .aspx pages using HTTPCompression, the postback will not works. Because it also compressing the Scripresource.axd, webresource.axd file.
To make the postback works in your project you do not compress the above two files, by adding these code.
Solution:
........, <httpcompress compressiontype="GZip"> <excludedpaths> <add path="scriptresource.axd"> <add path="webresource.axd"> </add> </add> </excludedpaths></httpcompress>
.., <excludedmimetypes> <add mime="image/jpeg"> </add> </excludedmimetypes>
My site is worth$16,159.24Your website value?