Store and retrieve the content on page postback. - asp.net

I want to store the content in a format like this, and be able to retrieve after page postback. Can I use a Hidden field? If so which datatype (not string?) Stringbuilder ?
<b>Email Template:</b> UserAssignment
<b>TO:</b> manojp.nayak#gmail.com<b>CC:</b>
<b>FROM:</b>admin#gmail.com <b>SUBJECT:</b>Task Assignment Project Activity has been assigned to you.
<b>BODY:</b> Deliverable Information :
Test Deliverable 01 Test Issue 01
Project Activity assigned by: Admin at: 2013-01-29 7:50 PM
Automated Email Notification. Do not reply.
Email Comments: 123test
<b>FILES:</b>

Sure you can.
you can use something like:
<asp:HiddenField ID="HiddenField_data" runat="server" />
And from code behind on your event you can save the value you want in here with something like:
HiddenField_data.Value = #"<b>Email Template:</b> UserAssignment
<b>TO:</b> manojp.nayak#gmail.com<b>CC:</b>
<b>FROM:</b>admin#gmail.com <b>SUBJECT:</b>Task Assignment Project Activity has been assigned to you.
<b>BODY:</b> Deliverable Information :
Test Deliverable 01 Test Issue 01
Project Activity assigned by: Admin at: 2013-01-29 7:50 PM
Automated Email Notification. Do not reply.
Email Comments: 123test
<b>FILES:</b> ";

You can use User Control to encapsulate your content
Visibility : You can use Visible property of your user control
Persistance : You can use EnableViewState property
Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.usercontrol(v=vs.80).aspx

Related

Shopware5 order confirmation email event

After a long investigation, I am not able to find the correct event to use JUST before the order confirmation email is sent.
I need to add a value in the s_order_attributes table which will be included in the email template.
I tried many events (e.g. checkout) but they are all triggered after the email ones.
thanks !
Looking at the code when the email is sent I assume there are two events you can try. You can either try Shopware_Modules_Order_SendMail_FilterVariables or sOrder::sendMail::before. These are executed right before the sending. If the attributes are not loaded from the database anymore in that moment you can set the public variables in sOrder to change the values that get into the mail. This might help you out as well but I prefer the FilterVariables event as it gives you direct access to the variables.

error in adding an updated timestamp with a button

I have a kiosk app running to check visitors in & out of specific offices. The checkedIn time is generated as an event tied to the model. In the events, I have an onCreate setup to record.checkedIn = new Date ();
The problem I have run into is on the Desk Clerks side of things. They have access to a table listing who is checked in. I want a button in each row that they can click to check out that individual. I setup the button under its onClick property to
record.checkedOut = new Date();
They both use the same datasource. However, whenever I click the button in preview the debug reports:
E
Tue Apr 04 10:14:24 GMT-700 2017
record is not defined
at signInAdmin.Panel1.Table1Panel.Table1.Table1Body.Table1Row.Button1.onClick:1:1
That's probably because 'record' is not defined in the context of onClick.
You should be able to get the record by accessing the data source property of the widget.
Try something like:
widget.datasource.item.checkedOut = new Date();

How to simulate onblur event with Robot Framework

I am automating login scenario of an application.
The execution steps are as below:
Select the Country
Enter the Username
Enter the Password
Click on Login Button.
Actually after entered the username, application validates the country and username in database exists or not.
When tried to automate through robot framework, this validation is not called and so unable to login (actually login button is clicked through script, but no error message or no response user is in same page).
When i verified exact scenario it calling the validation, comes to know that
validation is called on onblur of the usename element onblur="getlocation()".
I tried to simulate this by give tabout from username field through script as
Press Key ${element path} \\9 but it is not working always out of 10 run only 3 or 4 times it working.
Is there any way we can do 'blur` action on the element in robot framework
In the Selenium2Library for robot, there is a special keyword for that:
Simulate <element> <event>
In my keyword definition it looks like this:
I Enter The New Password
[Arguments] ${text}
Input Text ${INPUT_ELEMENT_PASSWORD} ${text}
Simulate ${INPUT_ELEMENT_PASSWORD} blur
http://robotframework.org/Selenium2Library/Selenium2Library.html#Simulate
I hope that helps, it took us a while to figure out what was missing in the test.
Just to save few minutes of googling.
Simulate
is deprecated. Use
Simulate Event
instead

Send an ok/cancel confirm with database data? ASP.Net VB

Can someone help me with this:
I want to send a confirm message to the user if a button is clicked. But the problem is that I want server data on the message.
For Example:
|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
| You are going to delete |
| 4 messages, are you sure? |
| |
| |OK| |Cancel| |
|___________________________|
The number 4 is brought from database with a Stored Procedure.
If the user clicks OK it should do some other code, if cancel is clicked, it should just return...
This is for a website on ASP.net using Visual Basic.
Please help!
Update:
After #T.S. answer I came up with this:
'Method for receiving the number...
'messages = numberReceived
Page.ClientScript.RegisterStartupScript(Me.GetType, "Confirmation", "<script> if (confirm('You will delete " & messages.ToString & " messages, are you sure?')) { ConfirmOnClean() }; </script>", False)
And the javascript function ConfirmOnClean() gets called correctly. What can I do to call a method on the codebehind after the user clicked OK?
Update:
I Finally solved it by Just adding a hidden field on the form:
<asp:HiddenField ID="cleanStatus" Value="dontClean" runat="server" />
And then on the Confirm on clean function I just did:
function ConfirmOnClean() {
$('#<%=cleanStatus.ClientId %>').val('clean');
__doPostBack('<%=btnClean %>','');
}
And on the Page_Load method on my codebehind I added:
If cleanStatus.Value.Equals("clean") Then
OnConfirm() 'Method for calling the stored procedure for deleting the messages.
End If
I hope this helps someone!
Your question is lacking concrete code. So here is one option:
Assume you have some Id. You call stored proc
Dim message as String
Using cmd as new SqlCommand(...
cmd.ExecuteNoQuery()
' retrieve your parameters here
message = cmd.Parameters(0).Value
End Using
Now code returns to the user with the values you retrieved. You can register script block to show the message immediately on the page http://msdn.microsoft.com/en-us/library/z9h4dk8y%28v=vs.110%29.aspx
When user User clicks Ok, you can, for example, set a hidden field with a value and invoke postback. YOur aspx page will read the value and invoke DB-call to delete values.
You need to provide more details to get more concrete solution here

ASP.NET see if member is online

I'm developing a ASP.NET site in umbraco, and I need to see if a member with a given ID is online. How can I do that?
So far, I've tried to get the member by so:
Member m = new Member(myID);
But how can I check, if the returned member is logged in or not?
EDIT: I followed the link, and extracted the following code from it:
var users = Membership.GetAllUsers();
foreach(MembershipUser user in users){
Response.Write(user.IsOnline.ToString() +"<br/>");
Response.Write(user.LastActivityDate.ToString() + "<br/>");
Response.Write(user.LastLoginDate.ToString() + "<br/>");
}
However, the returned result shows that the property isOnline is true for every member, even though they're not online. I'm aware that it is because of the fact that the LastActivityDate updates automatically whenever I access the user, as stated here: Is it possible to access a profile without updating LastActivityDate?. Unfortunately, I don't get the solution to that question.
I've also tried to access the member by:
MembershipUser m = Membership.GetUser('myID',false);
But even though I put false as the second parameter, the LastActivityDate still updates. How can I work around this? I should note that I work with ASP.NET v. 4.0 in umbraco 4.7 at a localhost.
Thanks!
:EDIT END
Best regards,
Brinck10
You can use the MembershipUser.IsOnline Property that show true if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the lastActivityDate for the user.
There is an example on the MSDN page.
relative:
Proper 100% IsOnline implementation for asp.net membership
How to check in ASP.NET if the user is online?
asp.net custom membership provider: IsOnline property
The solution to the problem:
(1) I made a costum field in the membertype called lastActivityDate.
(2) I placed a macro on the masterpage, update the member's lastActivityDate to the current time given that the member was online.
(3) On the validation page I checked if the lastActivityDate + CostumBuffer was bigger than DateTime.Now.
Thanks for your patience Aristos.

Resources