Our asp.net application uses EXT.NET.
When a "View" menu is clicked, an EXT.NET window shows up with a content of a PDF file.
The problem is we can't drag and drop that window to a body of an Outlook email (to make it as the email attachment).
I am thinking one of the way to drag and drop to a body of an Outlook email is to show the PDF file in the browser window, not an EXT.NET window. How can I do that ?
Thank you.
This is from the View (Index.cshtml):
#{
ViewBag.Title = "Archive";
var X = Html.X();
}
#section SPAViews {
#(
X.Viewport().Layout(LayoutType.Fit).Items(
X.TabPanel().ID("ArchiveTabPanel")
.Items(
X.GridPanel().ID("GridPanel1").MarginSpec("1 1 1 1").Cls("cust-grid").Title("Archive").Icon(Icon.ServerCompressed)
.Plugins(X.GridFilters())
.View(Html.X().GridView().StripeRows(true).TrackOver(false))
.SelectionModel(X.CheckboxSelectionModel().Mode(SelectionMode.Multi))
.TopBar(
X.Toolbar().MinHeight(35)
.Items(
:
, X.Button()
.Text("View")
.Icon(Icon.PageWhiteAcrobat)
.DirectEvents(de =>
{
de.Click.Action = "Submit";
de.Click.EventMask.ShowMask = true;
de.Click.Method = HttpMethod.POST;
de.Click.ExtraParams.Add(new Parameter()
{
Name = "selection",
Value = "getselection()",
Mode = ParameterMode.Raw
});
de.Click.Timeout = 360000;
})
This is from ArchiveController.cs:
public ActionResult Submit(string selection)
{
int cnt = SetTempData(selection);
RenderWindows(String.Format("View Archive {0}.",cnt),0,cnt);
return this.Direct();
}
[ChildActionOnly]
public void RenderWindows(string title,int download,int cnt)
{
Window win = new Window
{
ID = "Windows1",
Title = title,
Icon = Ext.Net.Icon.PageWhiteAcrobat,
Height = download == 1 ? 150 : 600,
Width = download == 1 ? 400 : 800,
BodyPadding = 2,
Modal = true,
Layout = "Fit",
CloseAction = CloseAction.Destroy,
Loader = new ComponentLoader()
{
Url = Url.Action("ArcTicket", "Archive"),
Mode = LoadMode.Frame,
DisableCaching = true,
ShowWarningOnFailure = true,
LoadMask = { ShowMask = true, Msg = String.Format("Generating {0} pdf ...",cnt) }
},
Buttons = {
new Button(){ Text="Close & Clear", Icon=Ext.Net.Icon.TableRowDelete, Handler="App.GridPanel1.selModel.deselectAll();App.Windows1.close();"},
new Button(){ Text="Close", Icon=Ext.Net.Icon.Cancel, Handler="App.Windows1.close();"}
}
};
win.Loader.Params.Add(new Parameter() { Name = "download", Value = download.ToString(), Mode = ParameterMode.Value });
win.Render(RenderMode.Auto);
}
public FileStreamResult ArcTicket(int download)
{
String id = TempData["xid"].ToString();
TempData.Remove("xid");
String ticket = Uow.TICKETs.GetXmlBatch(id);
Byte[] pdf = MvcApplication.Fop.Write(enumFobFormat.Pdf
, ticket
, Server.MapPath("/Resources/xslt/Ticket.xsl")
);
MemoryStream ms = new MemoryStream(pdf);
FileStreamResult fs = new FileStreamResult(ms, "application/pdf");
if (download == 1)
fs.FileDownloadName = string.Format("Archive_{0:yyyyMMdd_HHmmss}.pdf", DateTime.Now);
return fs;
}
You can make normal button / link with href to ArcTicket action with target="_blank" then it will be opened in new tab
Update:
Change .TopBar to something like this. Option 1 may be problematic because of dynamic parameter from grid and i am not sure it will be possible to pass it there
Option 1:
.TopBar(
X.Toolbar().MinHeight(35)
.Items(
:
, X.Button()
.Text("View")
.Icon(Icon.PageWhiteAcrobat)
.Href(Url.Action("ArcTicket", "Archive"))
.HrefTarget("blank")
.BaseParams("yourparameters")
Option 2
.TopBar(
X.Toolbar().MinHeight(35)
.Items(
:
, X.Button()
.Text("View")
.Icon(Icon.PageWhiteAcrobat)
.Handler("YourJSFUnctionWithWIndowOpen")
Related
How can i make custom Prompt?
I tried with code below..
public static string ShowDialog(string text, string caption) {
Form prompt = new Form() {
Width = 500,
Height = 150,
FormBorderStyle = FormBorderStyle.FixedDialog,
Text = caption,
StartPosition = FormStartPosition.CenterScreen
};
Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK };
confirmation.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(textBox);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.AcceptButton = confirmation;
return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "";
}
And then am using it like below
public bool OnJSDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage) {
if(dialogType.ToString() == "Prompt") {
//Form prompt = ShowDialogClass.ShowDialog("as", "asd");
string promptValue = Components.ShowDialog("Test", "123");
if (promptValue != "") {
callback.Continue(true, promptValue);
} else {
callback.Continue(false, "");
};
};
But i am getting error.
System.InvalidOperationException: 'Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.'
return false;
}
How can i implement this dialog to show custom prompt?
Few months too late but, here you go.
You are trying to create a new Form(your prompt form) inside another thread. In this case your CEF browser thread that will create a object from class IJsDialogHandler will be on another thread than the prompt message thread so you have to Cross the thread to access it.
The way you do this is "Invoke"(saying something like "wo wo don't worry, i know what i'm doing"). When you use "Invoke" your asking for a witness, well that witness should have the same kind of capabilities as your prompt message box form so.... in this case form that creates the CEF browser. so the code should be something like this
public bool OnJSDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage) {
if(dialogType.ToString() == "Prompt") {
if (ParentForm.InvokeRequired)
{
ParentForm.Invoke((MethodInvoker)delegate ()
{
string promptValue = Components.ShowDialog(messageText, "Prompt Message");
if (promptValue != "") {
callback.Continue(true, promptValue);
} else {
callback.Continue(false);
}
}
}
suppressMessage = false;
return true;
}
}
ParentForm should be changed to the name of the form that initialize the CEF browser.
I have a problem. My Problem is I can not pass parameters from RootPageMenuItem to Constructer of Content Page.
my code:
new RootPageMenuItem { Id = 4, Title = "myTitle", ImageSource = "rightArrow.png", TargetType = typeof(myContentPage) },
I want to achieve this:
new RootPageMenuItem { Id = 4, Title = "myTitle", ImageSource = "rightArrow.png", TargetType = typeof(myContentPage(_param1,_param2)) },
How can i do this?
Solution:
if(item.TargetType == typeof(myContentPage))
{
//This will create instance of the page using the parameterized constructor you defined in each DetailPages
Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType, param1 ,param2));
}
else
{
Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
}
Here is a similar issue which you can refer .
I'm using the Devexpress MVC Grid and I've added two custom buttons (Edit & Copy) and I'm performing the operations. With copy button, I'm creating a new record with existing data and opening the grid in Add New Row Mode.
Following is the code:
#Html.DevExpress().GridView(grid =>
{
grid.Name = "gvInformation";
grid.SettingsDetail.AllowOnlyOneMasterRowExpanded = true;
grid.SettingsEditing.Mode = GridViewEditingMode.EditForm;
//Callback Events
grid.CallbackRouteValues = new { Controller = "Case", Action = "InformationGridContent"};
grid.SettingsEditing.AddNewRowRouteValues = new { Controller = "Case", Action = "AddInformationRecord" };
grid.SettingsEditing.UpdateRowRouteValues = new { Controller = "Case", Action = "UpdateInformationRecord" };
grid.SettingsEditing.DeleteRowRouteValues = new { Controller = "Case", Action = "DeleteInformationRecord" };
grid.ClientSideEvents.BeginCallback = "BeginGridCallback";
grid.BeforeGetCallbackResult = (sender, e) =>
{
MVCxGridView gridView = sender as MVCxGridView;
if (isCopyRequired)
gridView.AddNewRow();
if (gridView.IsNewRowEditing)
{
gridView.SettingsText.CommandUpdate = Html.Raw("<span id='btnGridAdd'>Add</span>").ToHtmlString();
gridView.SettingsText.CommandCancel = Html.Raw("<span id='btnGridCancel'>Cancel</span>").ToHtmlString();
}
if (!gridView.IsNewRowEditing)
{
gridView.SettingsText.CommandUpdate = Html.Raw("<span id='btnGridUpdate'>Update</span>").ToHtmlString();
gridView.SettingsText.CommandCancel = Html.Raw("<span id='btnCancel'>Cancel</span>").ToHtmlString();
}
};
//Custom Copy Record Button
var btnCopy = new GridViewCommandColumnCustomButton { ID = "btnCopy" };
btnCopy.Text = "<i class=\"fa fa-copy fa-lg\" title='Copy'></i>";
grid.CommandColumn.CustomButtons.Add(btnCopy);
//Custom Edit Button
var btnEdit = new GridViewCommandColumnCustomButton { ID = "btnEdit" };
btnEdit.Text = "<i class=\"fa fa-pencil fa-lg\" title='Edit'></i>";
grid.CommandColumn.CustomButtons.Add(btnEdit);
//Custom Button Events
grid.ClientSideEvents.CustomButtonClick = "OnCustomButtonClick";
grid.CustomActionRouteValues = new { Controller = "Case", Action = "CustomInformationRecord" };
}
Client Side Events:
var buttonCommand;
function OnCustomButtonClick(s, e) {
buttonCommand = e.buttonID;
s.PerformCallback();
}
function BeginGridCallback(s, e) {
//Grid Edit Button Click Event
if (buttonCommand === "btnEdit") {
e.customArgs["buttonCommand"] = "btnEdit";
}
//Grid Copy Button Click Event
if (buttonCommand === "btnCopy") {
e.customArgs["buttonCommand"] = "btnCopy";
}
}
It is working fine for Copy button and opening the Grid in Edit Form Mode but when Edit Button is clicked it is not opening the Grid in Edit Mode. Is there something I'm missing?
How to use rotativa PDF to get my view in an asp.net mvc Area. In Area rotativa always return a blank PDF. Out of Area it's working fine.
I already try:
public ActionResult Report()
{
return new ViewAsPdf("Report") {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
And :
public ActionResult Report()
{
return new ViewAsPdf("Report", new { area = "Admin" }) {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
Specifying the full route in the viewName parameter worked for me. Not sure what your controller is, I'll assume its "Blah"
So if your route to the .cshtml is \Areas\Admin\Views\Blah\Report.cshtml then use:
public ActionResult Report()
{
return new ViewAsPdf("~\Areas\Admin\Views\Blah\Report.cshtml") {
FileName = "Report.pdf",
PageSize = Size.A3,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 0, Right = 0 }
};
}
I have a dynamically generated menu (C#), like this:
MenuItem(string text, string value, string imageUrl, string navigateUrl, string target)
MenuItem AdminLevel1 = new MenuItem("Admin", "Admin"); MenuItem AdminPedidosRegisto = new MenuItem("Questions", "AdminQ");
NavigationMenu.Items.Add(new MenuItem("Messages Received", "AdminMessagesR", "", "./Admin/Messages.ascx", "ContainerIframe")); AdminPedidosRegisto.ChildItems.Add(new MenuItem("Pending", "AdminPending", "", "./Admin/Pedidos.ascx", "ContainerIframe"));
Where 'ContainerIframe' is the iFrame's ID and 'NavigationMenu' is the (asp:Menu)'s ID.
I want to disable the click action in the parent items that don't have an URL set, so the page doesn't refresh when someone clicks it.
Is there a way?
menuitem.NavigateUrl = "javascript:;";
Thanks to #Manibhadra (this is enough for parent items and child items)
window.onload = function ()
{
var menuTable = document.getElementById("<%=NavigationMenu.ClientID%>");
var menuLinks = menuTable.getElementsByTagName("a");
for (i = 0; i < menuLinks.length; i++)
{
menuLinks[i].onclick = function () { }
}
}
if (MenuItem.NavigateUrl == "")
{
MenuItem.Selectable = false;
}