I have been trying to follow this blog http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2013/1/Upload-within-Xform/
The form upload works, however the file does not appear in the email, but is uploaded onto the server, so its doing something.
The instructions I have are...
Just attach to the
BeforeSubmitPostedData event
Check if ((e.FormData.ChannelOptions & ChannelOptions.Email) != ChannelOptions.Email) is true
then send the custom mail and remove the send mail option
e.FormData.ChannelOptions &= ~ChannelOptions.Email;
If anyone could simplify this for me, would be appreciated...
Many Thanks.
Marc.
in Application_Start in your global.asax you need to attach to the XFormControl.ControlSetup Event
protected void Application_Start(object sender, EventArgs e)
{
XFormControl.ControlSetup += new EventHandler(XForm_ControlSetup);
}
Then in your XForm_ControlSetup method, attach to the relevant event
public void XForm_ControlSetup(object sender, EventArgs e)
{
XFormControl control = (XFormControl)sender;
control.BeforeSubmitPostedData += new SaveFormDataEventHandler(XForm_BeforeSubmitPostedData);
}
And in your XForm_BeforeSubmitPostedData method
public void XForm_BeforeSubmitPostedData(object sender, SaveFormDataEventArgs e)
{
// Untested
if ((e.FormData.ChannelOptions & ChannelOptions.Email) != ChannelOptions.Email)
{
// Send custom mail here
// Remove the send mail option
e.FormData.ChannelOptions &= ~ChannelOptions.Email;
}
// End untested :)
}
Related
I have a .NET Application that I need to alter some WCF traffic headers on. The Microsoft folks told me there is no way to really inject the headers I need in the request and pick them up out of the response with the current framework. What I would like to do is just add FiddlerCore to the application, and if the header isn't there on the outgoing request from my application, then I would like to add it. (Real simple).
I can get everything to work, however the events only fire if I register the FiddlerApplication as a system proxy. I would like this transparent to the user so that it doesn't screw up their proxy settings in the OS.
private void Form1_Load(object sender, EventArgs e)
{
Fiddler.FiddlerApplication.SetAppDisplayName("FiddlerCoreTester");
Fiddler.FiddlerApplication.RequestHeadersAvailable += this.RequestHeadersAvailable;
Fiddler.FiddlerApplication.BeforeRequest += this.BeforeRequest;
Fiddler.FiddlerApplication.AfterSessionComplete += this.SessionComplete;
FiddlerApplication.OnNotification += this.OnNotification;
Fiddler.FiddlerApplication.ResponseHeadersAvailable += this.ResponseHeadersAvailable;
Fiddler.URLMonInterop.SetProxyInProcess("127.0.0.1:80", "<-loopback>");
Fiddler.FiddlerApplication.Startup(80, false, false);
WebClient wc = new WebClient();
string s = wc.DownloadString("http://www.google.com");
System.Windows.Forms.MessageBox.Show(s);
Fiddler.FiddlerApplication.Shutdown();
}
private void ResponseHeadersAvailable(Session oSession)
{
}
private void OnNotification(object sender, NotificationEventArgs e)
{
}
private void SessionComplete(Session oSession)
{
}
private void RequestHeadersAvailable()
{
}
private void BeforeRequest(Fiddler.Session oSession)
{
if (oSession.RequestHeaders.Exists("TESTHEADER") == false) {
oSession.RequestHeaders.Add("TESTHEADER", "TEST");
}
}
The events never get called in this case, however if I change this over to the below it does:
Fiddler.FiddlerApplication.Startup(80, true, false);
Does anyone know how to get this working?
Thanks so much
You should let your webclient use FiddlerCore as the proxy. You need to do this by setting the proxy of the webclient equal to proxy url that Fiddler listens to. Now your webclient loads the string through http://127.0.0.1:80 and Fiddler can capture your request.
WebClient wc = new WebClient();
wc.Proxy = new WebProxy(new Uri("http://127.0.0.1:80"));
string s = wc.DownloadString("http://www.google.com");
Fiddler.FiddlerApplication.Shutdown();
How can i upload a file without clicking submit button & also how to delete this uploaded file in asp.net? I can only upload but i can't delete this uploaded file.My CODE BEHIND SOURCE:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void UploadDocument(object sender, EventArgs e)
{
fuDocument.SaveAs(Server.MapPath("~/Documents/" + Path.GetFileName(fuDocument.FileName)));
lblMsg.Visible = true;
}
}
}
To upload a file, you can use javascript - there are many examples of this on SO and the web in general. Such as:
https://cmatskas.com/upload-files-in-asp-net-mvc-with-javascript-and-c/
You say that you "Can't delete" the file. How are you trying to delete it and what happens when you try? If it's an exception, what is the message and stack trace?
I want to send data to the server when you close the application
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Exit(object sender, EventArgs e)
{
ClientReverse.UserExitGameAsync((Guid)Login);
}
Server:
public void UserExitGame(Guid UserGuid)
{
Games.Games.ExitUserGames(UserGuid);
}
but the server side is not satisfied.
It is already too late when you reach the ApplicationExit event.
I have seen Javascript that keeps on a webpage until confirmed (Stack Overflow does it a lot). You might want to modify a version of that Javascript that sends a message back to the Silverlight app before it allows page closing.
Calling Silverlight methods from JS is easy (you can simply expose SL methods to JS with the [Scriptable] attribute).
Hello
I have a problem in my Design which is in this http://archive.msdn.microsoft.com/wfxbap/Release/ProjectReleases.aspx?ReleaseId=4668
I have made a custom activity in my Re-hosted workflow designer in WPF, and I make this custom activity shows in the end-user toolbar with the other activites, but the custom one can't be drop into the sequence at all like other activities.
I put the AllowDrop="True" in the .XAML file and the following in the .cs file:
protected override void OnDragEnter(DragEventArgs e)
{
//Check the object is actually something we want to be droppable
if (DragDropHelper.AllowDrop(
e.Data,
this.Context,
typeof(Activity)))
{
e.Effects = (DragDropEffects.Move & e.AllowedEffects);
e.Handled = true;
}
base.OnDragEnter(e);
}
protected override void OnDragOver(DragEventArgs e)
{
//Check the object is actually something we want to be droppable
if (DragDropHelper.AllowDrop(
e.Data,
this.Context,
typeof(Activity)))
{
e.Effects = (DragDropEffects.Move & e.AllowedEffects);
e.Handled = true;
}
base.OnDragOver(e);
}
protected override void OnDrop(DragEventArgs e)
{
//droppedItem - may be a ModelItem or a newly instantiated object (from toolbox)
object droppedItem = DragDropHelper.GetDroppedObject(this, e, this.Context);
ModelItem canvasActivity = this.ModelItem;
canvasActivity.Properties["Children"].Collection.Add(droppedItem);
e.Handled = true;
DragDropHelper.SetDragDropCompletedEffects(e, DragDropEffects.Move);
base.OnDrop(e);
}
Any help please?
I realize this post is old but I just ran across this problem as well so thought I would post for anyone else who stumbles upon this. I found that adding your custom Activity library to the same binary path as your rehosted designer should do the trick.
I have a few users that are using a silverlight app that aren't recieving updates when a new release is published. Isn't this suppose to be automatic or perhaps I'm missing an option somewhere? I was also starting to think that maybe the XAP file is cached and I some how need to prevent that.
Any thoughts out there?
You need to write a few lines of code.
If you're familiar with 'one click' deployment then some of the options you're used to don't exist in Silverlight. You need to write the code yourself.
http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
if (Application.Current.IsRunningOutOfBrowser)
{
Application.Current.CheckAndDownloadUpdateAsync();
}
and then in your App() constructor :
Application.Current.CheckAndDownloadUpdateCompleted +=
new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
and an event handler :
void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
// http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html
if (e.UpdateAvailable)
{
MessageBox.Show("The application has been updated! Please close and reopen it to load the new version.");
}
else if (e.Error != null && e.Error is PlatformNotSupportedException)
{
MessageBox.Show("An application update is available, " +
"but it requires a new version of Silverlight. " +
"Please contact tech support for further instructions.");
}
}
It only auto updates if the developer performs the CheckAndDownloadUpdateAsync() call. See updates: http://timheuer.com/blog/archive/2009/07/10/silverlight-3-released-what-is-new-and-changed.aspx#oob