I'm a problem to open a infopath form using XmlFormView. Here you have the code:
SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
try
{
XmlFormView form = new XmlFormView();
String templateLib = "FormServerTemplates";
String xsnName = report + ".xsn";
form.XsnLocation = String.Format("{0}/{1}/{2}", SPContext.Current.Web.Url, templateLib, xsnName);
manager.AddWebPart(form, "TopZone", 0);
}
So I create a page and I add a xmlform webpart to see infopath report in a page. The problem is when I try to open the page:
A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file.
Correlation ID:51a2dcd8-d2fa-4d8b-ae13-1b5f9caa1c51
It's weird becouse I can open the same form when I click on the content type that i assigned in a document library, but in a page, it's impossible to see it. What's going on here?
Thank you
First, can you check the exception in the SharePoint logs and add it to the post?
They are located at C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\LOGS. You can use the correlation ID to find the exception.
Additionally, try using elevated privileges like this:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// your code here
});
Related
I am trying to upload images in my windows server VM "hosted on-premise" and make these images available publicly like www.example.com/imageFolder/cat.png.
This VM has IIS enabled (I am not sure if IIS is related here) and it is assigned a URL and available publicly.
Aside from any programming languages or frameworks, I just want to know if storing the image in the server and making it available via a link is possible? If so, how can I achieve it?
To clarify further:
I believe what I want is very simple and tedious.
Consider the following workflow:
Run an API that has end points to receive images on the server.
Store the messages in the server.
Return the link that points to the picture.
I want to know the procedure from the windows server side like
Do I need to set certain properties on the folder where I will store the images?
Do I need to add a site to show the images back to the user?
I am a developer and I am new to the Windows Server & IIS so I may not have all the fundamentals.
I made a sample by using ASP.NET MVC5. You can follow this article to upload image in MVC5 application.
Upload Images on Server Folder Using ASP.NET MVC
Then, I do some changes so that it can display the url of images..
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
Uri requestUri = HttpContext.Request.Url;
string baseUrl = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);
if (ModelState.IsValid)
{
try
{
if (file != null)
{
string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName));
file.SaveAs(path);
}
string link = baseUrl + "/Images/" + file.FileName;
ViewBag.FileStatus = "File uploaded successfully.";
//Return the url of image
ViewBag.FileLink = link;
}
catch (Exception e)
{
ViewBag.FileStatus = "Error while file uploading. Error message is "+e.Message;
}
}
return View("Index");
}
Index.cshtml add this to show url.
<div class="col-md-offset-2 col-md-10 text-success">
#ViewBag.FileLink
</div>
Don't forget to add a folder named Images to store images. After publishing, you also need to add it in published folder, otherwise error message will show that cannot find folder.
It works well.
Lightswitch provides a Logout button on the Home page by default, but I'd like to have the option to log out on other pages as well. Is it possible to place the logout button on multiple pages?
If you're working with the HTML client, this can easily be achieved by replacing the following line of code in the LightSwitch library's _determineButtons function: -
result.showLogOut = msls_shell.getHomeScreen() === navigationUnit.screen.details.getModel();
With the following line of code: -
result.showLogOut = true;
This function is located in Scripts\msls-?.?.?.js file and, in order for this type of library file change to be applied, you'll need to reference the un-minified version of the LightSwitch library by making the following change in your HTML client's default.htm file: -
<!--<script type="text/javascript" src="Scripts/msls-?.?.?.min.js"></script>-->
<script type="text/javascript" src="Scripts/msls-?.?.?.js"></script>
The question marks in the msls reference will need to mirror the version you're using e.g. msls-2.5.2.js (for Visual Studio 2013 Update 4).
The above approach will force the LogOut button to appear on every page. However, if you need more control over when the LogOut button appears, you could use the following alternative change in the _determineButtons function: -
result.showLogOut = window.msls.showLogOut;
Then, in the created method of each screen, set the msls.showLogOut property to true when you wish the button to appear and to false when you don't e.g.: -
myapp.BrowseContacts.created = function (screen) {
// Write code here.
msls.showLogOut = true;
};
You don't say what version or language. This is VB for VS2012, Lightswitch web application.
Add a button to the Screen Command Bar, call it Logout (you can choose an image for it in the Properties panel later if you want). Right click the button and select Edit Execute Code. Use the following:
Private Sub Logout_Execute()
Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(
Sub()
System.Windows.Browser.HtmlPage.Window.Navigate(New Uri("../LogOut.aspx", UriKind.Relative))
End Sub)
End Sub
Works for me.
Phil
I have a big problem with Internet Explorer 7 and 8.
SITUATION:
I have a FORM that build a Medical Prescription. When I hit the save button, the script saves the DomainObject on DB and set a boolean property (of panel where the form is added) called "saved" to true and a byte[] property called PDF with bytestream.
On RenderHead of Panel, I read this boolean and, if is true, I force the trigger of a hidden button with this code:
String js = "$('#" + printPDF.getMarkupId() + "').click();";
response.renderOnDomReadyJavaScript(js);
The button executes this code:
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(new ByteArrayResourceStream(pdf, "application/pdf"));
handler.setFileName("foo.pdf");
RequestCycle.get().scheduleRequestHandlerAfterCurrent(handler);
This code work perfecly on FF and Chrome. The Browser download windows appears and the user can save the PDF on HD.
Unfortunally, Internet Explorer has that damn security behavior that is triggered when a site require something to download. That warning require a user validation. A yellow Bar appear and the user is force to hit "Download".
screenshot http://imageshack.us/a/img198/1438/securityg.jpg
When I hit Download File, the form is submitted again with the exact state I had when I hit save the first time. So no previous INSERT on DB is already committed; The Session is resetted to the previous state etc...
The result is a double INSERT on DB of the Domain Ojbect.
Any clue to resolve this?
The problem is that you click download link programaticly instead to redirect browser to an URL or open an URL by JS window.open(url). Click a link looks like an unwanted operation that is sometimes restricted by browser.
We are using CR with Visual studio 2010 for our applicaton.
Following is the code which I am using for generating the report from collection of objects which I got from Webservice.
SampleReport report = new SampleReport();
report.SetDataSource(response.Items);
Then at WPF level, I am assigning report source to the viewer as follows.
this.reportViewer.ViewerCore.ReportSource = report;
Problem is it is asking me login credential. Which I believe interesting as All the information to generate the report is ready to be picked up from the collection assigned as datasource.
Let me know what these credential could be. or how to override the behaviour.
Note: The designer had designed the .rpt file from xml, that WCF service provided.
I have looked around in forums for solutions, they dont have much information except following :
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
CrystalDecisions.CrystalReports.Engine.Tables CrTables ;
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
The problem is, I can understand if I would be connecting to DB to get the data... But getting data from object collection should not require the credential.
I faced such a problem earlier. What I did to fix this:
In the Visual Studio designer make sure that the Crystal Report Viewer doesn't have a report source defined
In the Crystal Report designer open the Field Explorer and right click on Database Fields and make sure you have selected the correct database location using the Set Database location, also try the Log On or Off Server
This is part of the code to load the report:
rptDoc.Load("CrystalReport_Test.rpt")
rptDoc.SetDataSource(rptDataset)
CrystalReportViewer1.ReportSource = rptDoc
CrystalReportViewer1.RefreshReport()
Hope this helps.
Hi i am making a simple component in joomla having name image detail and i have to upload that image how can i upload image from backend. which one is better using extension or make custom. can you please share any good article for it. i have searched many more but due to lack of idea on joomla cannot find. hope you genius guys help me.
thanks i advance
Joomla Component for the exact scenario of your requirement will be very hard to find out. So you've two options:
1. Make your own component
2. Customize other similar type of component like gallery component
For uploading file from joomla component on admin if you're making your own component:
1. Just use move_uploaded_file php function.
2. copy this code, for joomla's standard fxn :
function upload($src, $dest)
{
jimport('joomla.client.helper');
$FTPOptions = JClientHelper::getCredentials('ftp');
$ret = false;
$dest = JPath::clean($dest);
$baseDir = dirname($dest);
if (!file_exists($baseDir)) {
jimport('joomla.filesystem.folder');
JFolder::create($baseDir);
}
if ($FTPOptions['enabled'] == 1) {
jimport('joomla.client.ftp');
$ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']);
$dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/');
if (is_uploaded_file($src) && $ftp->store($src, $dest))
{
$ret = true;
unlink($src);
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
} else {
if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors
if (JPath::setPermissions($dest)) {
$ret = true;
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR01'));
}
} else {
JError::raiseWarning(21, JText::_('WARNFS_ERR02'));
}
}
return $ret;
}
If you want to use other's component and edit it according to need, download it:
http://prakashgobhaju.com.np/index.php?option=com_showcase_gallery&view=items&catid=1&Itemid=64
Remember it's a gallery component.
Uploading any file be it an image on your Joomla site is something which is so simple, and can be done using either the web based FTP and or the desktop FTP services like filezilla but only when you have saved the file you want to upload. Using the web based way, you need to log in to your host for example 000webhost, locate the file manager option, click on it and enter your domain username and password. Then go to public_html folder , create a new folder for your photos or images and click on upload. Locate your image and click on the tick link to start uploading.
Using the desktop way, you will need to unzip your file to add to joomla, open your FTP client like filezilla, locate the file on local host, input your log in details as provided by your host and once you are logged in to your account through filezilla, locate where you want to add the file and click on upload.
You can find a similar tutorial with regard here http://www.thekonsulthub.com/how-tos/how-to-upload-joomla-with-filezilla-to-your-hosting-servers-cpanel/ {entire thing}
Please please please make sure you use the filtering available in the MediaHelper. Specifically never trust uploaded images, always check first that they are valid file types, then that they are in the list of approved types of files listed in your global configuration, that the names do not contain html or javascript, and that the files themselves do not contain code. In particular I would recommend the MediaHelper::canUpload method which will check the majority of these things for you. If anything you should be checking even more strongly. Also make sure that you are checking whether the user has permission to upload. If anything you should make the checking even more restrictive. Use the APIs that joomla gives you, such as the built in media field.