Confirmation Box in SPItemEventReceiver class - c#

I want to display a confirmation box in SpItemEventReceiver class using just C# or any script or plugin (e.g. jQuery) with it.
I have researched the problem and I believe that I can do something like build a string and display it on this item adding form but I read it in this SharePoint King blog post (I am NOT advertising them) that it's not possible if you search for the text. Here's an excerpt:
Is there any way we can show a custom message box when an event is
fired and continue with the event?
No, that is not possible from the method described here.
You can put alert on button click of the form by the javascript but
can not be done by an event handler.
I wonder if someone can confirm whether can or we can't do it, as I think we can but don't know how. Here's a piece of code I'm trying:
class className: SPItemEventReceiver
{
public override void ItemAdding(SPItemEventProperties properties)
{
try
{
this.DisableEventFiring();
//Display a Message box here
[Edit:] Will the HttpContext.Response property work in this context?

Showing a message box won't work here; if it worked the message box would be shown on the server because that's where this code runs. What you could use server-side is the SharePoint
Page Status MSDN

Related

Telegram Bot make InlineKeyboardMarkup buttons unclickable

Is there any way to make InlikeKeyBoardMarkup buttons unclickable after user click on any button in? I've searched in google and as far as I understand I can only disappear ReplyKeyboardMarkup buttons, what does not satisfies me.
I am using Telegram-Bot library in C#
Can't be done visually but there is an alternative I've been using for a while:
Use editMessageReplyMarkup method and generate same keyboard layout but the button you want to become unclickable set as callback_data type with value like null or any other value you won't be using, clicking it will send Callback Query to the bot which you can simply not answer to or answerCallbackQuery it instantly (the 'clock' icon on the button will instantly disappear).
You can just delete the message of the question or edit it to say something like:
"I asked you if you like me and your replied of course."

C# Reflecting label value from another application within dialog box, on to the label of own application

I have created application and I also have another application which I have no source code of, another application has dialog box with the label which displays progress status of the current job in percentages, it looks like this:
What I am trying to achieve is to capture status of this label, and keep updating label which I had created within my own application.
As far as I understand I have to use WM_GETTEXT or WM_COPY functions, but I do not even know where to start, by the way I know how to use FindWindow function.
So far I have managed utilising spy++ to capture information about the main window:
Handle:0020040A
Caption: Import
Class: TfrmProgress
And also I could get a class and handle of the window within the main window, highlighted below:
The class and handle are:
Handle: 00080610
Class: Tpanel
Additional
I have also managed to retrieve handle and class of progress bar:
Handle: 00090400
Class: TProgressBar
Question
How can I reflect status of the label from this dialog box onto the label within my application or reflect the progress bar?
Reason
I am trying to achieve this because this dialog box is not available all the time e.i. it only appears sometimes and it took me a long time trying to capture it. But I want to see the progress of the given to the application task.
Thank you and any help would be welcome.

Looking for controls on parent page from DevExpress ASPXPopUpControl

good sirs!
I've been messing around with the next scenario:
First, I have a webform structured as a WebForm containing a DevExpress ASPXPopUpControl and some other controls. Inside the PopUpControl there is a UserControl (lets call it ucA) containing some other controls and a UserControl (called ucB) that contains a cursed ASPxHtmlEditor (added because it's a new requirement).
When the user hits a button on main webform I show the PopUp (originally was a jQuery dialog but since HTMLEditor messes up with jQuery I've been forced to break the standard and use the popup) which contains the ucA. The user fills some fields in ucA and hit the save button. After user hits, I save some dataz and at this point I need to recover a textbox value placed in the webform.
I'm using Parent.FindControl["myTextBox"] but it considers the popupcontrol as parent. When I was using jQuery (before implementing the editor) it worked like a charm.
I feel it's something trivial but thrust me when I say that this stole many hours of research.
Thanks in advance.
EDIT I forgot to mention that I want to look for another UserControl at main webform. This uc its used to display core messages to the user so when he hits the save button, save happens, popup is closed and i look (Parent.FindControl("myUCMessageBoard")) from the ucA for the usercontrol to display a "Transaction complete" message.
I'm thinking you're going to have to do something a little hacky, by using ViewState. If I understand correctly, you are trying to get access to a TextBox's Text on the Web Form, from a UserControl nested within a PopupControl (so you can't traverse all the way up to Web Form Level).
So, what I'd do at some point in the process is store the text in a ViewState variable that you can access from the User Control. It's not optimal, but since you're already hacking to get it to work, what's a little more hacking?
You should expose all controls from ucA as properties, then look for the control inside the DevxPopup the same way you doing. Given that all the controls that you need at the ucA has properties to access them, you could do all the logic you need!
Example:
public ucA : UserControl
{
public string myTextBoxText
{
get
{
return ((TextBox)Controls.FindControl("myTextBox")).Text;
}
}
/*And lot of controls*/
}
Then you looking for the popup at the Form
var ucA = (UcA)Form.Controls.FindControl("myPopup").Controls.FindControl("myucA");
ucA.myTextBoxText = /*Do stuff here with the text*/
Hopes this help you!

Winform App - Webpage Interaction

Windows Form Application – Manipulating input-elements in WinForm WebBrowser
Although I am familiar with HttpWebResponse/HttpWebRequest to login to a website, I was trying it now via using the mshtml library and found some weird behavior and I would like to see if someone else might be able to help me out here..
I have an HTML login page with a java backend with a Username field, a Password field and a Button.
The logic is very basic, I have a built a winform app with a built in webbrowser.
At the Document_Completed event I use the following code to enter my settings and to click the button.
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser.Url.ToString() == #"MyWebPage/signin")
{
HTMLDocument hdc = new HTMLDocumentClass();
hdc = (HTMLDocument)webBrowser.Document.DomDocument;
IHTMLElement elb = hdc.getElementById("login_button");
IHTMLInputElement elu = (IHTMLInputElement)hdc.getElementById("username");
IHTMLInputElement elp = (IHTMLInputElement)hdc.getElementById("password");
try
{
elu.value = "MyID";
elp.value = "MyPwd";
elb.click();
}
catch { }
}
}
Apart for this code being very quick and without error handling, it should do the trick and it does, partially..
There are two scenario's:
I launch the tool, it loads the webpage.
The tool populates the UserID field and the Password field correctly
The tool fails to click the button
I click the button manually, I am logged in, I click logout, I am back at login page
I immediatly logged in again, the tool enters the information
The tool immediatly clicks the button as well.
Is there anyone who might be able to explain me why this happens and how I could get around this with the current setup (hence not using HttpWebRequest). I don't see the difference between loading the page at startup or being redirected after logout, but apparently there is a difference in there or I am doing something wrong.
Any feedback on this matter is very much appreciated.
Thanks,
Kevin
EDIT:
I added a Button to my Windows Form that bas the same backend Code as below in order to click the button on the webpage, this works perfectly.
I triggered clicking this button in the webBrowser_Completed event but it doesn't work.
For some reason, everything I add to the webBrowser_DocumentCompleted event does not allow me to trigger the click event for the button in my WebBrowser control. Once that entire event has completed, if I then try to trigger it it works but I would like to automate this.. Any advice?
This might be a long shot and not the most elegant workaround but how about letting a backgroundworker run for a second in your DocumentCompleted event that then triggers the button that you clicked from it's seperate thread. This might just get this automated.
As this will run from a different thread, keep in mind that you might have to invoke certain controls so this might be another downside to this workaround..
If this doesn't work then, as Regfor previously suggested, Watin.org can help you out.
how about this :
HtmlElement button = webBrowser.HtmlDocument.GetElementById("login_button");
button.InvokeMember("click");
it works in my program.

touch screen clear status message on any touch

Iam working on a touch screen windows form that has many checkboxes, textboxes, listboxes, date dropdown pickers etc. Depending on user action a status message is displayed at the bottom. For eg., Your profile saved successfully, From and to date cannot be same, Please select a valid ... etc
What is an elegant way to clear the status message on ANY touch.
if (statusLabel.text != string.empty )
statusLabel.text = string.empty)
Meaning if any checkbox is checked, any text is input in a textbox, any listbox or combo is selected...then I want to clear the status label. This way the last status message does not "stick" to confuse the user. I am poking around to see if I can override some event at the form level in one place that will do this.
thanks
thx Saravanan and Pedery for your suggestions. They do not solve my problem. I just discovered Reactive extensions and posting a related question which may help me. Left mouse button click detect on winform using Reactive extensions IObservable on events
Try to find an event in the statusbar itself like text changed or content changed etc. Override it to clear the content of itself.
You may write code to clear the status bar content on the change event of the control's container.
Its your choice.
You can put the message in the controls' Tag property and use a single common event to add them all up.
If you wanna be more orderly, you can subclass the checkbox with a custom property the same way.
This was the solution to my problem
protected override void WndProc(ref Message msg)
{
switch(msg.Msg)
{
case WM_LBUTTONDOWN:
//Do something here
break;
//add other cases if needed
}
// call the base class WndProc for default message handling
base.WndProc(ref msg);
}

Categories

Resources