Evernote, sample "Hello World" code error using Visual Studio 10 WebForm - evernote

I am using a Visual Studio 2010 WebForm application to post a simple note to EverNote using the sample code for "Hello world. Here is the Code:
private void btnSubmit_Click(object sender, EventArgs e)
{
ENNote myPlainNote = new ENNote();
ENSession.SetSharedSessionDeveloperToken(
"My Developer
Token","https://www.evernote.com/shard/s308/notestore");
myPlainNote.Title = "My First Notes";
myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello
World!);
ENNoteRef myPlainNoteRef =
ENSession.SharedSession.UploadNote(myPlainNote, null);
}
I get "Object reference not set to an instance of an object" on the last line. I would really appreciate if someone could guide this newbie to resolve this issue.

UploadNote requires a second parameter to indicate in which notebook you want the new note created.
You can pass it an ENNotebook; for example, you could get such an object like this:
List<ENNotebook> myNotebookList = ENSession.SharedSession.ListNotebooks();
ENNotebook desiredNotebook = myNotebookList.Find(i => i.Name == "The name of my desired notebook");
You should also be able to pass a second parameter of null to add the note to your default notebook.

Related

How to pass query string parameter to ssrs reports from report viewer control

In my 2012 asp.net web form application, one of the aspx pages that contains asp.net report viewer control is coded
in its Page_Load event handler as below to call remote ssrs (SQL Server 2012) reports using property ReportPath.
I have 2 questions:
Question 1: If I want to pass one more query string via property ReportPath, for example deviceId=1234, how can I do so?
protected void Page_Load(object sender, EventArgs e)
{
....
ReportViewer1.ServerReport.ReportPath = _myReportPart; // I want to pass more query string here like deviceId=1234. How can I do so?
ReportViewer1.ServerReport.ReportServerUrl = new Uri(myReportServerUrl);
}
}
Question 2: on remote ssrs rdl reports, how can reports consume/extract that extra query string?
Thank you.
For adding parameters to the report in asp.net you can do the following
ReportParameter rpt7 = new ReportParameter(**PARAMETER NAME**, **VALUE**);
this.ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { rpt7 });
From the above example you could replace the value with Request.QueryString["deviceId"].ToString() to pass the query strings value as the parameter.
See the following for more details
http://social.msdn.microsoft.com/Forums/en/sqlreportingservices/thread/72fdf94f-2b5d-4fc3-82c4-7db887033507
As for the report excepting the extra parameter you would have to modify the report in Visual studio to except the new parameter. This can be done under the Report Data window's parameters section.

ClientScript.RegisterStartupScript NOT working on server

I'm having troubles with the following piece of code. It works really good in my local machine, but when I deploy it in the dev server it doesn't work at all. I've searched in a lot of places for a solution but with not successfully.
I have a gridview in which one column is a buttonfield. This button field opens a popup displaying the detail of the selected sales order.
In order to show the popup I use the following sentence:
private void OpenPopup(string name_)
{
Page.ClientScript.RegisterStartupScript(typeof(home), "Popup", string.Concat("<script type='text/javascript'>OpenPopup('", name_, "');</script>"));
}
The OpenPopup() is a javascript function which simply displays the popup (I've tested it and it works fine, so I wont show unnecessary code):
When RegisterStartupScript is executed in my local enviroment it works fine and the result in the page source is the following:
<script type='text/javascript'>OpenPopup('items');</script>
Now, when I publish the site and deploy it in the server it doesn't work at all. I've already tried to make it work using Scriptmanager, but with the same result; it works locally but not in the server.
The added script isn't being written at all.
I really apretiate any kind of help. I've already searched a lot with lots of approaches but no solution for me...
Thanks a lot.
/Edit: I do not use updatepanel in the page.
Have you tried using .RegisterClientScriptBlock? This is what I always use in order to call the JS in the codebehind.
Could you try something like the code below?
protected void btnSubmit_Click(object sender, EventArgs e)
{
Boolean dne = false;
StringBuilder errorMessage = new StringBuilder();
String scriptName = "";
if (AdminAccess.DoesUserExist(txtUsername.Text))
{
errorMessage.Append("alert('The selected username " + txtUsername.Text + " is already in use. Please choose another. ');");
scriptName = "duplicateUsername";
if (!ClientScript.IsClientScriptBlockRegistered(scriptName))
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), scriptName, errorMessage.ToString(), true);
}
dne = true;
}
}

Passing parameter ot RDL report for ASP.NET

I am trying to call rdl reports remotely in ASP.NET, And i was successful calling report without parameter. But when i pass parameter, reporting i not populating and not giving error. It display noting in report. find my code below. and please do suggest me on the same.
MyReportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
MyReportViewer.ServerReport.ReportServerUrl = new Uri(#"http://gblon9sqm10 /ReportServer_DB10");
MyReportViewer.ServerReport.ReportPath = "/Reports/Report1";
MyReportViewer.ShowParameterPrompts = false;
MyReportViewer.ShowPrintButton = true;
ReportParameter[] rptParameters = new ReportParameter[1];
rptParameters[0] = new ReportParameter();
rptParameters[0].Name = "exposureType";
rptParameters[0].Values.Add("Impressions");
MyReportViewer.ServerReport.SetParameters(rptParameters);
MyReportViewer.ServerReport.Refresh();
It's been a while since I set this up but I remember having to make sure that you didn't setup the report again on postback. This is my code in page_load:
if (!Page.IsPostBack)
{
rptViewer.ServerReport.ReportServerUrl = Settings.ReportServerUrl;
if (rptViewer.ServerReport.ReportServerCredentials == null)
rptViewer.ServerReport.ReportServerCredentials = new ReportServerCredentials();
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter("TitleLabel", "Title string here"));
//More parameters added here...
rptViewer.ServerReport.SetParameters(parameters);
}
I was facing the same problem with same code and configuration as you have mentioned.
I tried bit extra work and get the rid of problem.
I have created a new report with single parameter "Name" and pass value to this parameter from code-behind as ReportParameter. At the report configuration side set the type of parameter text and allow to blank values. Note here i didn't touch any other settings of parameter means kept it as comes by default.
This works for me and then i started adding more parameters and it works perfectly fine.
There is no any browser constraint.
Try as said above and still you face issue then reply me i will put a sample code.
Hope it will help you.

Javascript permission denied error when using Atalasoft DotImage

Have a real puzzler here. I'm using Atalasoft DotImage to allow the user to add some annotations to an image. When I add two annotations of the same type that contain text that have the same name, I get a javascript permission denied error in the Atalasoft's compressed js. The error is accessing the style member of a rule:
In the debugger (Visual Studio 2010 .Net 4.0) I can access
h._rule
but not
h._rule.style
What in javascript would cause permission denied when accessing a membere of an object?
Just wondering if anyone else has encountered this. I see several people using Atalasoft on SO and I even saw a response from someone with Atalasoft. And yes, I'm talking to them, but it never hurts to throw it out to the crowd. This only happens in IE8, not FireFox.
Thanks, Brian
Updates: Yes, using latest version: 9.0.2.43666
By same name (see comment below) I mean, I created default annotations and they are named so they can be added with javascript later.
// create a default annotation
TextData text = new TextData();
text.Name = "DefaultTextAnnotation";
text.Text = "Default Text Annotation:\n double-click to edit";
//text.Font = new AnnotationFont("Arial", 12f);
text.Font = new AnnotationFont(_strAnnotationFontName, _fltAnnotationFontSize);
text.Font.Bold = true;
text.FontBrush = new AnnotationBrush(Color.Black);
text.Fill = new AnnotationBrush(Color.Ivory);
text.Outline = new AnnotationPen(new AnnotationBrush(Color.White), 2);
WebAnnotationViewer1.Annotations.DefaultAnnotations.Add(text);
In javascript:
CreateAnnotation('TextData', 'DefaultTextAnnotation');
function CreateAnnotation(type, name) {
SetAnnotationModified(true);
WebAnnotationViewer1.DeselectAll();
var ann = WebAnnotationViewer1.CreateAnnotation(type, name);
WebThumbnailViewer1.Update();
}
There was a bug in an earlier version that allowed annotations to be saved with the same unique id's. This generally doesn't cause problems for any annotations except for TextAnnotations, since they use the unique id to create a CSS class for the text editor. CSS doesn't like having two or more classes defined by the same name, this is what causes the "Permission denied" error.
You can remove the unique id's from the annotations without it causing problems. I have provided a few code snippets below that demonstrate how this can be done. Calling ResetUniques() after you load the annotation data (on the server side) should make everything run smoothly.
-Dave C. from Atalasoft
protected void ResetUniques()
{
foreach (LayerAnnotation layerAnn in WebAnnotationViewer1.Annotations.Layers)
{
ResetLayer(layerAnn.Data as LayerData);
}
}
protected void ResetLayer(LayerData layer)
{
ResetUniqueID(layer);
foreach (AnnotationData data in layer.Items)
{
LayerData group = data as LayerData;
if (group != null)
{
ResetLayer(data as LayerData);
}
else
{
ResetUniqueID(data);
}
}
}
protected void ResetUniqueID(AnnotationData data)
{
data.SetExtraProperty("_atalaUniqueIndex", null);
}

Changing Databases in Crystal Reports for .NET

I have a problem which is perfectly described here (http://www.bokebb.com/dev/english/1972/posts/197270504.shtml):
Scenario:
Windows smart client app and the CrystalReportViewer for windows.
Using ServerFileReports to access reports through a centralized and disconnected folder location.
When accessing a report which was designed against DB_DEV and attempting to change its LogonInformation through the CrystalReportViewer to point against DB_UAT, it never seems to actually use the changed information.
It always goes against the DB_DEV info.
Any idea how to change the Database connection and logon information for a ServerFileReport ????
Heres code:
FROM A PRESENTER:
// event that fires when the views run report button is pressed
private void RunReport(object sender, EventArgs e)
{
this.view.LoadReport(Report, ConnectionInfo);
}
protected override object Report
{
get
{
ServerFileReport report = new ServerFileReport();
report.ObjectType = EnumServerFileType.REPORT;
report.ReportPath = #"\Report2.rpt";
report.WebServiceUrl = "http://localhost/CrystalReportsWebServices2005/ServerFileReportService.asmx";
return report;
}
}
private ConnectionInfo ConnectionInfo
{
get
{
ConnectionInfo info = new ConnectionInfo();
info.ServerName = servername;
info.DatabaseName = databasename;
info.UserID = userid;
info.Password = password;
return info;
}
}
ON THE VIEW WITH THE CRYSTAL REPORT VIEWER:
public void LoadReport(object report, ConnectionInfo connectionInfo)
{
viewer.ReportSource = report;
SetDBLogon(connectionInfo);
}
private void SetDBLogon(ConnectionInfo connectionInfo)
{
foreach (TableLogOnInfo logOnInfo in viewer.LogOnInfo)
{
logOnInfo.ConnectionInfo = connectionInfo;
}
}
Does anyone know how to solve the problem?
I know this isn't the programatic answer you're looking for, but:
One thing that helps with this sort of thing is not creating your reports connected to the database directly, but first you create a "Data Dictionary" for Crystal Reports (this is done in the Report Designer). Then you link all of your reports to this dictionary which maps the fields to the proper databases.
Done this way, you only have one place to change the database schema/connection info for all reports.
Also, in your report designer set the report to not cache the results (sorry I don't remember the exact option). Reports can either have their initial results included or not.
Don't you have to browse all the "databaseTable" objects of the report to redirect the corresponding connections? You'll find here my VB version of the 'database switch' problem ...
In your CrystalReportViewer object you should set
AutoDataBind="true"

Resources