ReportViewer errors in ASP.net - asp.net

I have been trying to get report viewer to work for several days now with no luck. I have followed several different tutorials but still no dice.
What I am trying to do is create a webform to allow the user to view a remote SRSS report with parameters. utilizing the following code:
protected void ddlTask_OnSelectedIndexChanged(object sender, EventArgs e)
{
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ServerReport serverReport = ReportViewer1.ServerReport;
serverReport.ReportServerUrl = new Uri("http://Server/reportserver");
serverReport.ReportPath = "/QAQC_Reports/" + sqlCommands.GetSpecificFormReportName(ddlType.SelectedValue);
ReportParameter BU = new ReportParameter("#BU", ddlBusinessUnit.SelectedValue);
ReportParameter TID = new ReportParameter("#TID", ddlTask.SelectedValue);
ReportViewer1.ServerReport.SetParameters(new[] { BU, TID });
}
on my aspx page I have the following:
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" ProcessingMode="Remote"></rsweb:ReportViewer>
I think I am almost there but I am getting the following error:
The permissions granted to user 'domain\computername$' are insufficient for performing this operation. (rsAccessDenied)

Related

Why is ScriptResource throwing Unknown Runtime Error on ReportViewer 12 drilldown?

Currently migrating an ASP.NET website which has embedded ReportViewer controls in the pages. The report shows up fine in the viewer, but when we click any drilldown link, IE indicates an "Unknown runtime error" in ScriptResource.axd. We are using ReportViewer 12, but had the same issue with ReportViewer 10; we thought upgrading to 12 would solve this, but it did not. I found a similar issue with updatePanel, but it was not helpful. I can post any additional information on request.
Error Message
Message: Unknown runtime error
Line: 1806
Char: 9
Code: 0
URI: http://{server-hostname}/{Path}/ScriptResource.axd?d=HURY6fWJG979L4dvjF7qlfDEC
Jny9VK-KMhlGWqyXlmaGtN_PSJwOijkOw__2eElLRRrfm_T1O2eGEITZnlywp
7rZLCcaeFP2C6YzKTzdcARY90AxK-TYzamRaw54Sjz1HmSjcvT
s_AbkVas-O2rxil2mMnRtfFW-zZTjHFDn0tcXJEiDnEzUdLZMJ
_oU2xf0&t=72e85ccd
web.config assembly references
<add assembly="Microsoft.ReportViewer.Common, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
<add assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"/>
Page Source
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Dashboard.aspx.cs" Inherits="Dashboard" Title="Dashboard" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div>
<p>
<rsweb:ReportViewer ID="rvDashboardMain" runat="server" Font-Names="Verdana" Font-Size="8pt"
ProcessingMode="Remote" EnableViewState="true" Width="95%" CssClass="rvFont"
ShowBackButton="true" ShowParameterPrompts="True" PromptAreaCollapsed="true" Height="520px">
<ServerReport ReportPath="/{my-report-path}/{my-report}" />
</rsweb:ReportViewer>
</p>
</div>
</asp:Content>
Code back page
public partial class Dashboard : System.Web.UI.Page {
protected void Page_Init(object sender, EventArgs e) {
if (!Page.IsPostBack) {
ServerReport serverReport = rvDashboardMain.ServerReport;
serverReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["ReportServer"]);
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string UserID = HttpContext.Current.User.Identity.Name;
UserID = UserID.Substring(UserID.IndexOf(#"\") + 1, UserID.Length - UserID.IndexOf(#"\") - 1);
}
}
protected void rvReports_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e)
{
ServerReport rpt = (ServerReport)e.Report;
rvDashboardMain.ServerReport.Refresh();
}
}
Anchor for the drillthrough link
<a
tabindex="26"
onclick="var rp=$get('ctl00_ContentPlaceHolder1_rvDashboardMain_ctl09_ReportControl');if(rp&&rp.control)rp.control.InvokeReportAction('Drillthrough','188iT0R0x0:0');return false;" onkeypress="if(event.keyCode == 13 || event.which == 13){var rp=$get('ctl00_ContentPlaceHolder1_rvDashboardMain_ctl09_ReportControl');if(rp&&rp.control)rp.control.InvokeReportAction('Drillthrough','188iT0R0x0:0');}return false;"
href=""
style="cursor:pointer;"
class="A1d3b265b4e26456c97f9dd1067b6eec2186a"
target="_top">2,551</a>

asp.net onclick event not fired

I'm facing a weird problem with my asp.net buttons.
All was fine, I was coding a webpart with some ajax panels and buttons, and it was just so near to be finished when a wild error appeared. All my buttons were firing the same method despite I didn't told then so.
Well, I found it was due to a known issue : http://forums.asp.net/t/1567526.aspx/1
I tried to delete the called method to see if the other buttons would go back to their assigned methods, and since then, no more event is fired by buttons.
No more... Never...
I put back the method, created a new webpart with new code, restored a backup of my site, reset my server, restarted Visual Studio, And finally I'm trying to create a whole new VS solution with a whole new code. I've just a page with one lonely asp button, And nothing happens...
ascx file :
<%# Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%# Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%# Import Namespace="Microsoft.SharePoint" %>
<%# Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="PublicationUserControl.ascx.cs" Inherits="CripmeeWebParts.Publication.PublicationUserControl" %>
<asp:Button ID="Valider" runat="server" Text="Valider" />
ascx.cs file
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace CripmeeWebParts.Publication
{
public partial class PublicationUserControl : UserControl
{
protected override void OnLoad(EventArgs e)
{
EnsureChildControls();
base.OnLoad(e);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
Valider.Click += new EventHandler(Valider_Click);
}
void Valider_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
I've tied all this :
attach event on the ascx code or on the CreateChildControls, use onCommand event, place button in a <form>, attach debugger to w3 process to see if it go through all my methods.
I'm just out of ideas...
Thank you for reading, any suggestion would be usefull.
here comes the solution I've found.
I still don't know why the event disappeared, but I notice that they are not fired only when I display the webpart from administration panel (site action>settings>webpart library> click on my custom webpart). If I add my webpart to a test page, all is working fine. If someone else have the same issue, I hope he will read this and avoid the week I've lost...
Thank you all for your time and answers :)
just put this
Valider.Click += new EventHandler(Valider_Click);
in Page_Load() or Page_Init() I can't see where you call CreateChildControls()
try
Valider= new Button();
Valider.Text = "Valider";
Valider.Click += new EventHandler(VAlider_Click);
Controls.add(Valider)
in your CreateChildControls
Your button needs an OnClick event declared
<asp:Button ID="Valider" runat="server" Text="Valider" OnClick="Valider_Click"/>
or Call your CreateChildControls in Page_Load

Page postback twice on the page having reportviewer

My problem is, the aspx page is getting reloaded twice if the page having ReportViewer control.
This is the code am having in my .aspx page,
My problem is, the aspx page is getting reloaded twice if the page having ReportViewer control.
This is the code am having in my .aspx page,
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> <br><br>
and ..
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana" Font-Size="7pt" Width="100%" Height="500px"
BackColor="#FAE28C" WaitControlDisplayAfter="10000" Visible="false" />
And this is in my code behind,
ReportDataSource rds =
new ReportDataSource
("dsSource", _PendingTicketAgeBC.SelectDailyTicketAgeInQueue(_SomeBE));
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
ReportViewer1.LocalReport.ReportPath = Server.MapPath(".") + "\\Somereport.rdlc";
ReportParameter paramHedaer = new ReportParameter();
paramHedaer.Name = "paramHeader";
paramHedaer.Values.Add(mHeaderparam);
ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { paramHedaer });
ReportViewer1.Visible = true;
Can anyone direct me the right way to resolve the issue. Thanks in advance.
I had this issue and was resolved by setting the AsyncRendering to false on the ReportViewer control. Note the the default value is true. Hope that helps

Autocomplet extender control in ajax (asp.net)?

I am using autocomplete extender in my application but it is not working. This is my code:
<form id="form1" runat="server">
<asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div>
<cc1:AutoCompleteExtender TargetControlID="TextBox1" MinimumPrefixLength="1"
ServiceMethod="GetVideoTitles" CompletionSetCount="10" ServicePath="Myservices.asmx" ID="AutoCompleteExtender1" runat="server">
</cc1:AutoCompleteExtender>
</div>
</form>
This is the webservice method:
public string[] GetVideoTitles(string prefixText)
{
SqlConnection con = new SqlConnection(#"Data Source=SERVER5\SQLserver2005;Initial Catalog=tpvnew;User ID=xx;Password=525");
con.Open();
SqlCommand cmd = new SqlCommand("video_videotitles", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#prefixText", SqlDbType.VarChar, 50);
cmd.Parameters["#prefixText"].Value = prefixText;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["videotitle"].ToString(), i);
i++;
}
return items;
}
Have you tried setting a breakpoint in your GetVideoTitles method, and verified that it returns any items?
Try this trick
public string[] GetVideoTitles(string prefixText) {
try
{
...Your code...
foreach (DataRow dr in dt.Rows)
{
items.SetValue(dr["videotitle"].ToString(), i);
Debug.Write(dr["videotitle"].ToString());
i++;
}
...Your code...
}
catch(Exception)
{
Debug.Assert(false);
}
}
This way you first locate if somthing stop running on webservice method.
Also use the DebugView from sysinternals to check live the data you get from Debug.write()
Debug View
Hope this 2 thinks help you locate the bug.
-- Found this on asp.net forums--
http://forums.asp.net/t/1123944.aspx
In most cases where the WebService method does not get calls becasue the WebMethod Signature does not match with the AutoComplete Extender signature. The Method signature needs to be:
string[] WSMethodName(string prefixText, int count)
You can have different method name but the parameter names and return type needs to be exact match even in case.
Reading this page
http://www.vishwamohan.com/post/2007/05/07/AJAX-Error-Sys-is-undefined.aspx
and this page
http://blogs.imeta.co.uk/TAxworthy/archive/2009/01/15/569.aspx
Found that the sys problem can solve that way....
The most important line was:
allowDefinition="MachineToApplication"
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
When compared to the application’s web.config, the last section was missing. When this line was amended, the javascript error was fixed, and the AJAX controls worked correctly again.
Try to see if your web method GetVideoTitles() works or not.
if it works, then check if you have set your .asmx web service path in the scriptmanager.
<asp:ScriptManager ID="smMain" runat="server">
<Services>
<asp:ServiceReference Path="~/WebServices/AutoComplete.asmx"/>
</Services>
</asp:ScriptManager>
you miss this
da.SelectCommand.Parameters.Add("#prefixText", SqlDbType.VarChar, 50).Value = **prefixText + "%"**;
and in your query must use
like #prefixText

ASP.NET 2.0 Asynchronous User Control Not Working

I'm trying to get a user control working asynchronously, yet no matter what I do it continues to work synchronously. I've stripped it down to its bare minimum as a test web application. This would be the user control:
<%# Control Language="C#" %>
<script runat="server">
SqlConnection m_oConnection;
SqlCommand m_oCommand;
void Page_Load(object sender, EventArgs e)
{
Trace.Warn("Page_Load");
string strDSN = ConfigurationManager.ConnectionStrings["DSN"].ConnectionString + ";async=true";
string strSQL = "waitfor delay '00:00:10'; select * from MyTable";
m_oConnection = new SqlConnection(strDSN);
m_oCommand = new SqlCommand(strSQL, m_oConnection);
m_oConnection.Open();
Page.RegisterAsyncTask(new PageAsyncTask(new BeginEventHandler(BeginHandler), new EndEventHandler(EndHandler), new EndEventHandler(TimeoutHandler), null, true));
Page.ExecuteRegisteredAsyncTasks();
}
IAsyncResult BeginHandler(object src, EventArgs e, AsyncCallback cb, object state)
{
Trace.Warn("BeginHandler");
return m_oCommand.BeginExecuteReader(cb, state);
}
void EndHandler(IAsyncResult ar)
{
Trace.Warn("EndHandler");
GridView1.DataSource = m_oCommand.EndExecuteReader(ar);
GridView1.DataBind();
m_oConnection.Close();
}
void TimeoutHandler(IAsyncResult ar)
{
Trace.Warn("TimeoutHandler");
}
</script>
<asp:gridview id="GridView1" runat="server" />
And this would be the page in which I host the control three times:
<%# page language="C#" trace="true" async="true" asynctimeout="60" %>
<%# register tagprefix="uc" tagname="mycontrol" src="~/MyControl.ascx" %>
<html>
<body>
<form id="form1" runat="server">
<uc:mycontrol id="MyControl1" runat="server" />
<uc:mycontrol id="MyControl2" runat="server" />
<uc:mycontrol id="MyControl3" runat="server" />
</form>
</body>
</html>
The page gets displayed without errors, but the trace at the bottom of the page shows each control instance is processed synchronously. What am I doing wrong? Is there a configuration setting somewhere I'm missing?
Looks like I can answer my own question. The user control should not be calling Page.ExecuteRegisteredAsyncTasks. By doing that, the control was adding the async task, running it, and waiting for it to complete.
Instead, each instance of the user control should call only Page.RegisterAsyncTask. After each control instance has done this the page automatically calls RegistereAsyncTask running all three registered async tasks simultaniously.
So here is the new user control:
<%# Control Language="C#" %>
<script runat="server">
SqlConnection m_oConnection;
SqlCommand m_oCommand;
void Page_Load(object sender, EventArgs e)
{
Trace.Warn(ID, "Page_Load - " + Thread.CurrentThread.GetHashCode().ToString());
string strDSN = ConfigurationManager.ConnectionStrings["DSN"].ConnectionString + ";async=true";
string strSQL = "waitfor delay '00:00:10'; select * from TEProcessedPerDay where Date > dateadd(day, -90, getutcdate()) order by Date asc";
m_oConnection = new SqlConnection(strDSN);
m_oCommand = new SqlCommand(strSQL, m_oConnection);
m_oConnection.Open();
Page.RegisterAsyncTask(new PageAsyncTask(new BeginEventHandler(BeginHandler), new EndEventHandler(EndHandler), new EndEventHandler(TimeoutHandler), null, true));
}
IAsyncResult BeginHandler(object src, EventArgs e, AsyncCallback cb, object state)
{
Trace.Warn(ID, "BeginHandler - " + Thread.CurrentThread.GetHashCode().ToString());
return m_oCommand.BeginExecuteReader(cb, state);
}
void EndHandler(IAsyncResult ar)
{
Trace.Warn(ID, "EndHandler - " + Thread.CurrentThread.GetHashCode().ToString());
GridView1.DataSource = m_oCommand.EndExecuteReader(ar);
GridView1.DataBind();
m_oConnection.Close();
}
void TimeoutHandler(IAsyncResult ar)
{
Trace.Warn(ID, "TimeoutHandler - " + Thread.CurrentThread.GetHashCode().ToString());
}
</script>
<asp:gridview id="GridView1" runat="server" />
And the unchanged page that creates three instances of the control:
<%# page language="C#" async="true" trace="true" %>
<%# register tagprefix="uc" tagname="mycontrol" src="~/MyControl.ascx" %>
<html>
<body>
<form id="form1" runat="server">
<uc:mycontrol id="MyControl1" runat="server" />
<uc:mycontrol id="MyControl2" runat="server" />
<uc:mycontrol id="MyControl3" runat="server" />
</form>
</body>
</html>
If I may add a little to the above post, we should not call the ExecuteRegisteredAsyncTassk explicitly unless there is a compelling reason. once you register the async task, the ASP.NET framework will execute all these tasks right after the OnPrerender event of the page lifecycle.
An example for the usage of ExecuteRegisteredAsyncTasks could be;
Sometimes you may need to ensure that several async operations are completed before calling another async task. in a situation like this it is justifiable to use ExecuteRegisteredAsyncTasks.

Resources