I have a gridview with the following markup:
<asp:GridView ID="gv" runat="server" Width="700px" skinid="gridview" HeaderStyle-HorizontalAlign="Left" AllowPaging="true" PageSize="50" AllowSorting="true" CssClass="gv">
<SortedAscendingHeaderStyle CssClass="sort_asc" />
<SortedDescendingHeaderStyle CssClass="sort_desc" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Project" DataField="Project" SortExpression="Project" />
<asp:BoundField HeaderText="Type" DataField="Type" SortExpression="Type" />
</Columns>
</GridView>
However, my SortedAscendingHeaderStyle and SortedDescendingHeaderStyle CssClass's are not being applied to the HTML when sorting.
My CSS is:
.gv .sort_asc
{
display:block;
padding:0 4px 0 15px;
background:url(/Admin/Images/Icons/arrow_down.jpg) no-repeat;
}
.gv .sort_desc
{
display:block;
padding:0 4px 0 15px;
background:url(/Admin/Images/Icons/arrow_up.jpg) no-repeat;
}
What are the possible reasons for this?
Below is the way, the task can be accomplished:
In .aspx file
<asp:GridView ID="gvData" runat="server" SkinID="yourskinID"
AllowSorting="True" onsorting="gvData_Sorting">
<HeaderStyle CssClass="ascendingCssClass" /> <%-- put it into your SKIN file,
assume you're showing data in ascending initially --%>
<Columns>
</Columns>
</asp:GridView>
In .cs file
private const string ASCENDING = " ASC";
private const string DESCENDING = " DESC";
public SortDirection GridViewSortDirection
{
get
{
if (ViewState["sortDirection"] == null)
ViewState["sortDirection"] = SortDirection.Ascending;
return (SortDirection)ViewState["sortDirection"];
}
set { ViewState["sortDirection"] = value; }
}
protected void gvData_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
//Put your CssClass here for descending
gvData.HeaderStyle.CssClass = "descendingCssClass";
SortGridView(sortExpression, DESCENDING);
}
else
{
GridViewSortDirection = SortDirection.Ascending;
//Put your CssClass here for ascending
gvData.HeaderStyle.CssClass = "ascendingCssClass";
SortGridView(sortExpression, ASCENDING);
}
}
private void SortGridView(string sortExpression, string direction)
{
DataTable dt = GetData();
DataView dv = new DataView(dt);
dv.Sort = sortExpression + direction;
gvData.DataSource = dv;
gvData.DataBind();
}
Update:
The sample/test css is a below: I just have used it test purpose, use your appropriate styling.
tr.ascendingCssClass th a:link
{
color:Green;
background-color:White;
}
tr.ascendingCssClass th a:hover
{
color:Orange;
background-color:White;
}
tr.ascendingCssClass th a:visited
{
color:Black;
background-color:White;
}
tr.descendingCssClass th a:link
{
color: red;
background-color:Gray;
}
tr.descendingCssClass th a:hover
{
color: Yellow;
background-color:Gray;
}
tr.descendingCssClass th a:visited
{
color: Yellow;
background-color:Gray;
}
And, the DataTable function is as below:
DataTable GetData()
{
DataTable table = new DataTable("MyDataTable");
using (SqlConnection connection = new SqlConnection(YourConnectionString))
{
//Your data retrival code goes here
adapter.Fill(table); // Finally fill the datatable
}
return table;
}
Related
i just want to make data list with pagging. here is my code :
public partial class Template_Management : System.Web.UI.Page
{
PagedDataSource adsource = null;
int pos;
protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
adsource = new PagedDataSource();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
.....
Session["StartAlpha"] = "All";
Session["GroupByCategory"] = -1;
Session["ColumnName"] = null;
Session["SearchText"] = null;
this.FillGrid((String)Session["StartAlpha"] ?? null, (int)Session["GroupByCategory"], (String)Session["ColumnName"] ?? null, (String)Session["SearchText"] ?? null);
this.ViewState["vs"] = 0;
}
pos = (int)this.ViewState["vs"];
}
}
public void FillGrid(string StartAlpha, int GroupByCategory, string ColumnName, string SearchText)
{
if (myDataSet.Tables[0].Rows.Count > 0)
{
adsource.DataSource = myDataSet.Tables[0].DefaultView;
adsource.AllowPaging = true;
adsource.PageSize = 20;
DL_ViewTemplate.DataSource = adsource;
}
if (DL_ViewTemplate.Items.Count != 0)
{
SetPageNumbers();
}
UpdatePanel8.Update();
DL_ViewTemplate.DataBind();
}
private void SetPageNumbers()
{
foreach (DataListItem item in DL_ViewTemplate.Items)
{
if (item.ItemType == ListItemType.Footer)
{
if (pos == 0)
{
ImageButton img = (ImageButton)item.FindControl("ImageButton1");
img.Enabled = false;
}
if (pos == adsource.PageCount - 1)
{
ImageButton img = (ImageButton)item.FindControl("ImageButton4");
img.Enabled = false;
}
}
}
}
protected void DL_ViewTemplate_ItemCommand(object source, DataListCommandEventArgs e)
{
int intCurIndex = adsource.CurrentPageIndex;
switch (e.CommandArgument.ToString())
{
case "first":
adsource.CurrentPageIndex = 0;
break;
case "prev":
CurrentPage -= 1;
break;
case "next":
CurrentPage += 1;
break;
case "last":
adsource.CurrentPageIndex = adsource.PageCount;
break;
}
this.FillGrid((String)Session["StartAlpha"] ?? null, (int)Session["GroupByCategory"], (String)Session["ColumnName"] ?? null, (String)Session["SearchText"] ?? null);
}
protected void DL_ViewTemplate_ItemDataBound(object sender, DataListItemEventArgs e)
{
foreach (DataListItem item in DL_ViewTemplate.Items)
{
if (item.ItemType == ListItemType.Footer && item.ItemType == ListItemType.Item)
{
// get your controls from the gridview
DropDownList ddlPages = (DropDownList)item.FindControl("ddlPages");
Label lblPageCount = (Label)item.FindControl("lblPageCount");
if (ddlPages != null)
{
// populate pager
for (int i = 0; i < adsource.PageCount; i++)
{
int intPageNumber = i + 1;
ListItem lstItem = new ListItem(intPageNumber.ToString());
if (i == adsource.CurrentPageIndex)
lstItem.Selected = true;
ddlPages.Items.Add(lstItem);
}
}
// populate page count
if (lblPageCount != null)
lblPageCount.Text = adsource.PageCount.ToString();
}
}
}
protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (DataListItem item in DL_ViewTemplate.Items)
{
if (item.ItemType == ListItemType.Footer)
{
DropDownList ddlPages = (DropDownList)item.FindControl("ddlPages");
adsource.CurrentPageIndex = ddlPages.SelectedIndex;
//a method to populate your grid
this.FillGrid((String)Session["StartAlpha"] ?? null, (int)Session["GroupByCategory"], (String)Session["ColumnName"] ?? null, (String)Session["SearchText"] ?? null);
}
}
}
}
how ever footer control with ddl doesn't filled.
for more info i place html markup :
<asp:DataList ID="DL_ViewTemplate" runat="server" RepeatColumns="6"
ShowFooter="True" HorizontalAlign="Left" RepeatDirection="Horizontal"
DataKeyField="Id" onitemcommand="DL_ViewTemplate_ItemCommand"
ShowHeader="False" onitemcreated="DL_ViewTemplate_ItemCreated"
onitemdatabound="DL_ViewTemplate_ItemDataBound" CellPadding="1"
CellSpacing="3">
<ItemStyle HorizontalAlign="Left" Wrap="True" Width="40%" />
<ItemTemplate>
<div class="thumb" align="center" style="height:150px;width:130px">
<table width="40%" align="center">
<tr>
<td>
<asp:Literal ID="Literal4" runat="server"></asp:Literal><!-- Text=<'#Eval("TemplateBody")%>'-->
<ajaxToolkit:HoverMenuExtender ID="hme1" runat="Server"
TargetControlID="Literal4"
PopupControlID="Panel2"
DynamicContextKey='<%# Eval("Id") %>'
DynamicControlID="Panel2"
DynamicServiceMethod="GetDynamicContent"
PopupPosition="Right"
OffsetX="-25"
OffsetY="15"/>
</td>
</tr>
</table>
</div>
<table width="145px" align="left" style="border-color:Black;border-style:solid;border-width:1px;height:50px">
<tr>
<td align="center">
<table>
<tr>
<td><asp:CheckBox ID="ChkSelect" runat="server" onclick = "Check_Click(this)"/></td>
<td> </td>
<td><asp:LinkButton ID="LinkButton2" runat="server" CssClass="quicklink"
Text='<%# Eval("TemplateName").ToString().Length > 12 ? Eval("TemplateName").ToString().Substring(0,12)+"..." :Eval("TemplateName") %>' CommandName="ViewTemplate"
ToolTip ='<%# Eval("TemplateName")%>' CommandArgument='<%# Eval("Id") %>'></asp:LinkButton>
<br/>
<asp:Label ID="Label2" runat="server" CssClass="normaltext"
Text='<%# DataBinder.Eval(Container.DataItem, "CreatedDate", "{0:dd/MM/yyyy}") %>'
ToolTip='<%# Bind("CreatedDate","{0:F}") %>'></asp:Label></td>
</tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
<SeparatorTemplate> </SeparatorTemplate>
<FooterTemplate>
<table>
<tr>
<td>
<asp:ImageButton ID="ImageButton1" runat="server"
AlternateText="Go to First Page" CommandArgument="First" CommandName="Page"
ImageUrl="images/1330128819_resultset_first.png" />
</td>
<td>
<asp:ImageButton ID="ImageButton2" runat="server" AlternateText="Previous Page"
CommandArgument="Prev" CommandName="Page"
ImageUrl="images/1330128981_resultset_previous.png" />
</td>
<td>
Page <asp:DropDownList ID="ddlPages" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlPages_SelectedIndexChanged" Width="50px">
</asp:DropDownList>
of
<asp:Label ID="lblPageCount" runat="server"></asp:Label>
</td>
<td>
<asp:ImageButton ID="ImageButton3" runat="server" AlternateText="Next Page"
CommandArgument="Next" CommandName="Page"
ImageUrl="images/Farm-Fresh_resultset_next.png" />
</td>
<td>
<asp:ImageButton ID="ImageButton4" runat="server"
AlternateText="Go to Last Page" CommandArgument="Last" CommandName="Page"
ImageUrl="images/1330128876_resultset_last.png" />
</td>
</tr>
</table>
</FooterTemplate>
<FooterStyle CssClass="pager" VerticalAlign="Bottom"
HorizontalAlign="Center" />
</asp:DataList>
here i set adsource which was paged data source declared first and assigned in Page_Init() is it valid ?? because when ever other event want to access adsource then Object reference not found error thrown.
what am i going wrong please help me....
you can refer these links for more information on paging on datalist control in ASP.net
http://www.c-sharpcorner.com/UploadFile/718fc8/paging-in-datalist-control/
http://www.codeproject.com/Articles/14080/Implementing-Efficient-Data-Paging-with-the-Datali
I want to display an image in grid view cell on specific condition andthe condition fails image not to be display.
<asp:GridView ID="gvWrkLogVW" runat="server" AutoGenerateColumns="False"
onrowdatabound="gvWrkLogVW_RowDataBound"
>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Width="20px" Height="20px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
On row data bound
if (e.Row.RowType == DataControlRowType.DataRow)
{
Image img = (Image)e.Row.FindControl("Image1");
for (int i = 0; i < dtWorkLogDeatils.Rows.Count; i++)
{
if (dtWorkLogDeatils.Rows[i]["email"].ToString() == "True")
{
img.ImageUrl = "/images/mail_send.png";
}
else
{
img.ImageUrl = "";
}
}
}
the last binding image is repeating all the columns.How to assign the image to particular cell
I'm building web app using asp.net web forms and i have a SliderExtender in a TemplateField of a Grid View as below.
<ajaxToolkit:SliderExtender ID="SliderExtender1" runat="server" TargetControlID="txtbox_count"
BoundControlID="txtbox_count_BoundControl" Orientation="Horizontal" EnableHandleAnimation="true"
RailCssClass="SliderRail" HandleCssClass="SliderHandle" HandleImageUrl="~/Images/slider_h_handle.gif"
Minimum="0" Maximum='<%# double.Parse(Eval("VEHICLE_TYPE.MAX_AMOUNT").ToString()) %>'>
</ajaxToolkit:SliderExtender>
<asp:TextBox ID="txtbox_count" Width="25" runat="server" Text='<%# Bind("VEHICLE_AVAILABILITY.EXIST_COUNT") %>'
Style="text-align: right"></asp:TextBox>
<asp:TextBox ID="txtbox_count_BoundControl" Width="25" runat="server" Text='<%# Bind("VEHICLE_AVAILABILITY.EXIST_COUNT") %>'
Style="text-align: right"></asp:TextBox>
CSS of RailCssClass and HandleCssClass
.SliderHandle
{
position: absolute;
height: 22px;
width: 10px;
}
.SliderRail
{
position: relative;
background: url('../../Images/slider_h_rail.gif') repeat-x;
height: 22px;
width: 125px;
}
This looks like below.
But I need to customize the slider like below.
How can I do this? What should I change in my css class?
Here I have created example
Download sample from http://jqueryui.com/resources/download/jquery-ui-1.10.3.zip
include all necessory resource like jquery, CSS, images etc from demo into your project
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="WebForm2.aspx.cs" Inherits="TestSf.WebForm2" %>
<%# Register Src="SliderControl.ascx" TagName="SliderControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:GridView runat="server" ID="grd" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="MaxValue" HeaderText="MaxValue" SortExpression="MaxValue" />
<asp:TemplateField HeaderText="Slider">
<ItemTemplate>
<uc1:SliderControl ID="SliderControl1" runat="server" ctrlID='<%# Eval("ID") %>'
Maxvalue='<%# Eval("MaxValue") %>' Value='<%# Eval("Value") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<script type="text/javascript">
if(arr.indexOf($(this).val())>-1)
{
alert('This is already selected , please select other option');
return false;
}
</script>
</asp:Content>
c# Sample code
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<TestMax> lst = new List<TestMax>();
lst.Add(new TestMax() { ID = 1, MaxValue = 10, Value = 4, Name = "Sandeep" });
lst.Add(new TestMax() { ID = 2, MaxValue = 12, Value = 3, Name = "Nilesh" });
lst.Add(new TestMax() { ID = 3, MaxValue = 11, Value = 6, Name = "Jayesh" });
grd.DataSource = lst;
grd.DataBind();
}
}
public class TestMax
{
public int ID { get; set; }
public string Name { get; set; }
public int MaxValue { get; set; }
public int Value { get; set; }
}
Create a new USerControl and use this markup
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="SliderControl.ascx.cs"
Inherits="TestSf.SliderControl" %>
<script>
$(function () {
$("#slider-range-max<%= ctrlID %>").slider({ range: "max", min: 1, max: <%= Maxvalue %>,
value: <%= Value %>, slide: function (event, ui) { $("#amount<%= ctrlID %>").val(ui.value); }
});
$("#amount<%= ctrlID %>").val($("#slider-range-max<%= ctrlID %>").slider("value"));
});
</script>
<div id="slider-range-max<%= ctrlID %>">
</div>
<input type="text" id="amount<%= ctrlID %>" style="border: 2; color: #f6931f; font-weight: bold;" />
UserControl C# code
public partial class SliderControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public int ctrlID { get; set; }
public int Maxvalue { get; set; }
public int Value { get; set; }
}
You can apply styles using the following properties.
RailCssClass="ajax__slider_h_rail"
HandleCssClass="ajax__slider_h_handle"
and their styles as follows, which you can edit according to your requirements.
.ajax__slider_h_rail
{
position:relative;
height:20px;
}
.ajax__slider_h_handle
{
position:absolute;
height:20px;width:10px;
}
.ajax__slider_v_rail
{
position:relative;
width:20px;
}
.ajax__slider_v_handle
{
position:absolute;
height:10px;width:20px;
}
First thing, You are using AjaxControlToolkit slider while, expecting UI as jquery slider.
if you can switch the control, it will solve your issue.
otherwise,
put these css classes
.ajax__slider_h_rail {
border: 1px solid;
border-radius: 3px 3px 3px 3px;
height: 8px;
position: relative;
}
.ajax__slider_h_handle {
height: 22px;
position: absolute;
top: -7px !important;
width: 10px;
}
First use following code to stop showing the default image
.handleStyle img
{
display:none;
}
Then use whatever styles you are using for handle like following
.handleStyle
{
position: absolute;
height: 22px;
width: 22px;
background-color:Red;
border-radius:8px;
}
i need to call a web service without use webreference created with visual studio, i have to use
http web request i have the soap request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pos="http://posting.ws.rpg.snamretegas.it/">
<soapenv:Header/>
<soapenv:Body>
<pos:postAllReports>
<report_name>REPORT_SWITCH</report_name>
<report_date></report_date>
<i_ambiente>ITG1</i_ambiente>
<i_taxidOpco>TEST_YF1</i_taxidOpco>
</pos:postAllReports>
</soapenv:Body>
</soapenv:Envelope>
this is the code behind asp page:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OracleClient;
public partial class PubreportControl : System.Web.UI.Page
{
private DB_Utility dbu;
protected double size = 1;
private string connectionString;
private OracleConnection connection;
private OracleCommand processNumQuery;
private int indexdropitem;
private int coloreriga = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["CONNECTSTRING"] = Request["CONNECTSTRING"];
if (Session["CONNECTSTRING"] == null)
{
Response.Redirect("sessionup.asp?type=Pubreport");
}
connectionString = Session["CONNECTSTRING"].ToString();
if (connectionString.IndexOf("DSN=") >= 0)
{
Comuni.Utility util = new Utility();
connectionString = util.ConnStr(connectionString);
Session["CONNECTSTRING"] = connectionString;
}
connection = new OracleConnection(connectionString);
connection.Open();
dbu = new DB_Utility(Session["CONNECTSTRING"].ToString());
}
else
{
connectionString = Session["CONNECTSTRING"].ToString();
if (connectionString.IndexOf("DSN=") >= 0)
{
Comuni.Utility util = new Utility();
connectionString = util.ConnStr(connectionString);
Session["CONNECTSTRING"] = connectionString;
}
connection = new OracleConnection(connectionString);
connection.Open();
dbu = new DB_Utility(Session["CONNECTSTRING"].ToString());
}
if (!IsPostBack)
{
processNumQuery = new OracleCommand("select distinct nome_report from rpg_notification",connection);
OracleDataReader reader = processNumQuery.ExecuteReader();
while (reader.Read())
{
dropdownlist1.Items.Insert(0, new ListItem(reader.GetString(0), reader.GetString(0)));
}
reader.Close();
}
if(Request["txtSchedDate"] == null)
{
DateTime daDate = DateTime.Today;
txtSchedDate.Text = daDate.ToString("dd/MM/yyyy");
}
else
{
txtSchedDate.Text = Request["txtSchedDate"];
gwreportpub.DataSource = getDatiFromDb();
gwreportpub.DataBind();
DateTime schedDate = Convert.ToDateTime(Request["txtSchedDate"]);
string reportname = dropdownlist1.SelectedItem.Text;
object[] WSMethodArguments = new object[3];
WSMethodArguments[0] = reportname;
WSMethodArguments[1] = schedDate.ToUniversalTime().ToString("s");
WSMethodArguments[2] = "ITG1";
PageAsyncTask task = new PageAsyncTask(
new BeginEventHandler(BeginAsyncOperation),
new EndEventHandler(EndAsyncOperation),
new EndEventHandler(TimeoutAsyncOperation),
WSMethodArguments
);
RegisterAsyncTask(task);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//Response.Write("ciao " + dropdownlist1.SelectedIndex + " - " + dropdownlist1.SelectedItem.Text + " - " + dropdownlist1.Items[dropdownlist1.SelectedIndex].Text + " - " + Request["txtSchedDate"] + " - ");
//ThreadPool.QueueUserWorkItem(new WaitCallback(callWebService),new object[] {"http://172.19.241.235:9001/snam-rpg-ws/ReportPosting","ReportPosting","postAllReports",WSMethodArguments});
gwreportpub.DataSource = getDatiFromDb();
gwreportpub.DataBind();
gwreportpub.Visible = true;
if (gwreportpub.Rows.Count == 0)
{
tbnotif.Text = "Non vi sono report pubblicati";
tbnotif.Visible = true;
}
else{
tbnotif.Visible = true;
tbnotif.Text = "Tabella dei Report Pubblicati: ";
}
return;
}
void TimeoutAsyncOperation(IAsyncResult ar)
{
Response.Write("Pubblicazione Timeout");
}
IAsyncResult BeginAsyncOperation (object sender, EventArgs e,
AsyncCallback cb, object state)
{
object[] array = state as object[];
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(#"http://172.19.241.235:9001/snam-rpg-ws/ReportPosting");
webRequest.Headers.Add(#"SOAP:Action");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
HttpWebRequest request = webRequest;
XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:pos=\"http://posting.ws.rpg.snamretegas.it/\"><soapenv:Header/><soapenv:Body><pos:postAllReports><report_name> " + array[0] +" </report_name> <report_date> " + array[1] + "</report_date> <i_ambiente> " + array[2] + "</i_ambiente> <i_taxidOpco></i_taxidOpco></pos:postAllReports></soapenv:Body></soapenv:Envelope>");
using (Stream stream = request.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string soapResult = rd.ReadToEnd();
}
}
SampleMethodCaller smd = new SampleMethodCaller(SampleClass.SampleMethod);
IAsyncResult result = smd.BeginInvoke(null, null);
return result;
//return callWebService(new object[] {"http://172.19.241.235:9001/snam-rpg-ws/ReportPosting","ReportPosting","postAllReports",state});
}
public delegate bool SampleMethodCaller();
void EndAsyncOperation(IAsyncResult ar)
{
Response.Write("Pubblicazione Terminata");
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
}
public DataSet getDatiFromDb()
{
OracleDataAdapter adapter = new OracleDataAdapter();
OracleCommand orclc = new OracleCommand("select pubblicato, nome_report, data_report, md5 from rpg_notification where pubblicato = :flag and data_report <= TO_DATE(:repdate,'DD/MM/YYYY') and nome_report = :nome",this.connection);
orclc.Parameters.Add(new OracleParameter(":flag", OracleType.VarChar));
orclc.Parameters.Add(new OracleParameter(":nome", OracleType.VarChar));
orclc.Parameters.Add(new OracleParameter(":repdate", OracleType.VarChar));
orclc.Parameters[":flag"].Value = "Y";
orclc.Parameters[":nome"].Value = dropdownlist1.SelectedItem.Text;
orclc.Parameters[":repdate"].Value = Request["txtSchedDate"].ToString();
adapter.SelectCommand = orclc;
DataSet dt = new DataSet("rpg_notification");
adapter.Fill(dt,"rpg_notification");
return dt;
}
protected void GridView1_PageIndexChanging(object sender,
GridViewPageEventArgs e)
{
gwreportpub.PageIndex = e.NewPageIndex;
gwreportpub.DataBind();
}
protected void coloraRighe(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType==DataControlRowType.Header)
{
e.Row.BackColor = Color.Ivory;
}
else if (coloreriga == 2)
{
e.Row.BackColor = Color.LightYellow;
coloreriga = 1;
}
else
{
e.Row.BackColor = Color.WhiteSmoke;
coloreriga = 2;
}
}
}
public class SampleClass
{
public static bool SampleMethod()
{
return true;
}
}
please can you tell me why it dose not call the Ws ???
and please how can i debug this ??? you see something wrong in the code ??
i m getting crazy about the async pattern too
in the end the asp page:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Pubreport.aspx.cs"
Inherits="PubreportControl" Title="Untitled Page" Async="true" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<script language="javascript" type="text/javascript">
var size = 0;
var id= 0;
function add_gif() {
document.getElementById("Label1").style.display = "none";
show_image("./wait.gif", 300,15, "Running");
}
function show_image(src, width, height, alt) {
var img = document.createElement("img");
img.src = src;
img.width = width;
img.height = height;
img.alt = alt;
document.getElementById("divUpload").style.display="inline";
var div = document.getElementById("divUpload");
div.appendChild(img);
}
function show_table() {
document.getElementById("tbnotification").style.display="block";
}
</script>
<head id="Head1" runat="server">
<title>Pubblicazione Report</title>
<link rel="stylesheet" type="text/css" href="../controls/SnapIn.css" />
<link rel="stylesheet" type="text/css" href="../controls/lsi18n.css" />
<script type="text/javascript" src="../cust_batchrequest/calendario/prototype.js"></script>
<script type="text/javascript" src="../cust_batchrequest/calendario/scriptaculous.js"> </script>
<script type="text/javascript" src="../cust_batchrequest/calendario/datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../cust_batchrequest/calendario/datepicker.css" />
<style type="text/css">
.errorMessage
{
color: #8B0000;
text-align: center;
}
.confirmMessage
{
color: #006400;
text-align: center;
}
.datebox
{
text-align:center;
}
</style>
<style type="text/css">
.CCSListBox
{
width: 200px;
}
</style>
</head>
<body style="margin-left: 20%; margin-right: 20%">
<form id="form1" runat="server">
<table class="SnapIn" style="text-align: center; height: 100%; border: 0; background-color: #FFFFFF; width: 100%;
border: 3px solid #6699CC" cellpadding="0" cellspacing="0">
<tr class="ToolsRow">
<td class="Title" style="white-space: nowrap; width=20%">
Pubblicazione Report
</td>
<td style="width: 80%; text-align: right">
</td>
</tr>
<tr style="height: 5%">
<td colspan="2">
</td>
</tr>
<tr style="text-align: center;">
</tr>
<tr style="height: 15%">
<td colspan="2">
</td>
</tr>
<tr>
<td style="text-align: center" colspan="2">
<div style="text-align:center">
<b>Scegliere il nome del report * </b>
<asp:DropDownList id="dropdownlist1" style="width:250px;" runat="server"></asp:DropDownList>
<br />
<br />
<br />
<b>Scegliere la data del report </b>
<asp:TextBox runat="server" ID="txtSchedDate" name="txtSchedDate" type="text" cssclass="datebox" style="height:20px;" ReadOnly="true"/>
<br />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Pubblica" OnClientClick="show_table();" OnCommand="Button1_Click" />
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" Font-Names="Arial" Font-Size="15px" runat="server" ForeColor="Red" Font-Bold="True" Text=""></asp:Label>
<div id="divUpload" style="display:none">
<div style="width:200pt;;text-align:center;">Pubblicando...</div>
</div>
</div>
</td>
<br/>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<br />
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<br />
<table width="100%" id="tbnotification" class="Stripy" style="display:block;">
<tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:Label ID="tbnotif" runat="server" ReadOnly="True" Text="" >
</asp:Label>
</td>
</tr>
<tr>
<td>
<asp:GridView ID="gwreportpub" runat="server" CellPadding="5" BorderStyle="Solid" OnRowDataBound="coloraRighe" AllowPaging="true" PageSize="15" OnPageIndexChanging="GridView1_PageIndexChanging" style="border: 1px solid black;">
</asp:gridview>
</td>
</tr>
</tr>
</table>
</td>
</tr>
</table>
</form>
<script type="text/javascript">
var dpck_1 = new DatePicker({ relative: 'txtSchedDate', language: 'it' });
</script>
ok did an external client in java and i did produce a jar that call the webservice
after i did this for call the webserice inside the aspx page:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = "\"" + System.Web.HttpContext.Current.Server.MapPath(".") + "\\" + "ConsoleApp.jar" + "\"" ;
if(datarepo != "")
proc.StartInfo.Arguments = "\""+connectionString +"\"" + " " +"\"" +reportname+"\"" + " " +"\"" +datarepo+"\"" + " " +"\"" +opco+"\"" + " " + "\"" +ambienteParm+"\"";
else
proc.StartInfo.Arguments = "\""+connectionString +"\"" + " " +"\"" +reportname+"\"" + " " +"\"" + "\"" + " " +"\"" +opco+"\"" + " " + "\"" +ambienteParm+"\"";
proc.Start();
proc.WaitForExit();
//string result = proc.StandardOutput.ReadToEnd();
//Response.Write(result + " - " + proc.ExitCode);
proc.Close();
thxs to everyone.
script:
$(document).ready(function () {
$('#Custom').hide('fast');
$('#rbtnEntire').click(function () {
$('#Custom').hide('fast');
$('#Entire').show('fast');
});
$('#rbtnCustom').click(function () {
$('#Entire').hide('fast');
$('#Custom').show('fast');
});
});
function showdiv() {
document.getElementById("divChkList").style.display = "block";
}
aspx file:
<div style="height:700; width:500;">
<div id="select scan type">
<asp:RadioButton ID="rbtnEntire" runat="server" Text="Entire"
GroupName="s1"/>
<asp:RadioButton ID="rbtnCustom" runat="server" Text="Custom"
GroupName="s1"/>
</div>
<div id="Entire" style="float:left; height:1000; width:1000; border: solid 1px; margin-left:5px;">
Entire<br />
<asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All" ShowLines="True" ExpandDepth="2">
<Nodes>
<asp:TreeNode Text="Entire">
<asp:TreeNode Text="VM">
<asp:TreeNode Text="MBS1">
</asp:TreeNode>
<asp:TreeNode Text="PF1"></asp:TreeNode>
</asp:TreeNode>
<asp:TreeNode Text="VM1">
<asp:TreeNode Text="MBS2"></asp:TreeNode>
<asp:TreeNode Text="PF2"></asp:TreeNode>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
<p>
<asp:Button ID="btnCreateXML" runat="server" onclick="btnCreateXML_Click"
Text="Create XML" />
<asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
</p></div>
<div id="Custom" style="float:left; height:1000; width:2000; border: solid 1px; margin-left:10px;">
Custom <br />
<div id="Manual" style="border:solid 1px; float:left;">
Manual Scan Controls
</div>
<div id="Multiple" style="border:solid 1px; float:left;">
Multiple Scan Controls
<table>
<tr>
<td valign="top" style="width: 165px">
<asp:PlaceHolder ID="phDDLCHK" runat="server"></asp:PlaceHolder>
</td>
<td valign="top">
<asp:Button ID="btn" runat="server" Text="Get Checked" OnClick="btn_Click" />
</td>
<td valign="top">
<asp:Label ID="lblSelectedItem" runat="server"></asp:Label>
</td>
</tr>
</table>
</div>
<asp:HiddenField ID="hidList" runat="server" />
</div>
<br />
</div>
code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
initialiseCheckBoxList();
rbtnEntire.Checked = true;
try
{
TreeView1.Attributes.Add("onclick", "javascript: OnTreeClick();");
}
catch(Exception)
{
Response.Write("Error Occured While onTreeClick");
}
}
}
public void initialiseCheckBoxList()
{
CheckBoxList chkBxLst = new CheckBoxList();
chkBxLst.ID = "chkLstItem";
chkBxLst.Attributes.Add("onmouseover", "showdiv()");
DataTable dtListItem = GetListItem();
int rowNo = dtListItem.Rows.Count;
string lstValue = string.Empty;
string lstID = string.Empty;
for (int i = 0; i < rowNo - 1; i++)
{
lstValue = dtListItem.Rows[i]["Value"].ToString();
lstID = dtListItem.Rows[i]["ID"].ToString();
chkBxLst.Items.Add(lstValue);
}
System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl("div");
div.ID = "divChkList";
div.Controls.Add(chkBxLst);
div.Style.Add("border", "black 1px solid");
div.Style.Add("width", "160px");
div.Style.Add("height", "130px");
div.Style.Add("overflow", "AUTO");
div.Style.Add("display", "block");
}//end of initialiseCheckBoxList()
protected void btn_Click(object sender, EventArgs e)
{
string x=string.Empty;
string strSelectedItem = "Selected Items ";
CheckBoxList chk = (CheckBoxList)phDDLCHK.FindControl("chkLstItem"); // phDDLCHK is placeholder's ID
for (int i = 0; i < chk.Items.Count; i++)
{
if (chk.Items[i].Selected)
{
if (strSelectedItem.Length == 0)
{
strSelectedItem = strSelectedItem + ":" + chk.Items[i].Text;
}
else
{
strSelectedItem = strSelectedItem + ":" + chk.Items[i].Text;
}
}
}
lblSelectedItem.Text =strSelectedItem;
}
public DataTable GetListItem()
{
DataTable table = new DataTable();
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Value", typeof(string));
for (int icnt = 0; icnt < 10; icnt++)
{
table.Rows.Add(icnt, "ListItem"+":"+icnt);
}
return table;
}
Problem: When i Select radio button rbtnCustom, It should display div Custom along with the CheckboxList control,which is not happening. When I do not hide div,it is displayed. What can be done to display checkboxList control?
Here is my code, Can any one let me know where I went wrong?
Any help would be appriciated! Thanks!
The reason some of your Javascript isn't working is because you are using the server ID in the client side (Javascript) code.
<asp:RadioButton ID="rbtnCustom" runat="server" Text="Custom"
GroupName="s1"/>
Since the above control is set to runat="server" the ID attribute is setting a sever side control ID, the client ID will be generated. If you don't need access to this control on the server, it might be easier to simply use a 'input' element instead of an asp.net control. The other option would be to set the ClientIDMode="Static" so the client ID is the same as the server ID.
<asp:RadioButton ID="rbtnCustom" runat="server" Text="Custom" ClientIDMode="Static"
GroupName="s1"/>
Use this for any control if you are not setting the ID in the code behind and if you are using the ID in client side Javascript.
EDIT: You are also missing phDDLCHK.Controls.Add(div); at the end of your initialiseCheckBoxList method.
You are also not providing what javascript "OnTreeClick();" is. It is referenced in the code behind. From what I can tell you are only populating the contents of the custom checkboxlist once on the initialiseCheckBoxList.
How to use asp checkbox control as RadioButton
First we create a script like this:
<script type="text/javascript">
function check(sender) {
var chkBox;
var i;
var j;
for (i = 1; i < 6; i++) {
for (j = 1; j < 6; j++) {
if (i != j) {
if (sender.id == "ck" + i) {
chkBox = document.getElementById("ck" + j);
}
else {
chkBox = document.getElementById("ck" + i);
}
if (sender.checked) {
if (chkBox.checked) {
chkBox.checked = false;
}
}
}
}
}
}
</script>
Now we use following code for our ASP CheckBox controls
<div>
<asp:CheckBox ID="ck1" runat="server" Text="P1" onclick="check(this)"/>
<asp:CheckBox ID="ck2" runat="server" Text="P2" onclick="check(this)"/>
<asp:CheckBox ID="ck3" runat="server" Text="P3" onclick="check(this)"/>
<asp:CheckBox ID="ck4" runat="server" Text="P4" onclick="check(this)"/>
<asp:CheckBox ID="ck5" runat="server" Text="P5" onclick="check(this)"/>
</div>
Thank you...