I have two webforms (Default1.aspx and Default2.aspx). The Default.aspx has a label that represents login ID, and on the Default2.aspx, there is an input box like this
And I want to pass information from user session into the input box in Default2.aspx. I don’t know if it can be done though, but I used this;
The yellow highlighted area is used as the input ID because the javascript event which i am using from an external gateway has "email-address" fixed as the ID as shown below. So i want to pass information into the input having the same ID as the input, because
having a different ID from the above input will not load the script.
So i want to pass information into the input having the same ID as the input, because having a different ID from the above input will not load the script.
You can have same Id of controls as long as controls are in different pages. Session data can be easily shown in these controls.
What errors you are getting in achieving this??
Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
You have to change the name to something like 'emailAddress' because such names having '-' between then is not valid.
Helping you always. Don't forget to click "Mark as Answer" on the post that helped you.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
"Only combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. Including spaces or other invalid characters will cause an ASP.NET page parser error."
You won't be able to use that ID, even though you added runat="server" to the <input> tag. You need to re-think your design. Perhaps load a hidden field with the value and use JavaScript to add the value to the input tag.
I did change the name to "userid", but it did not rhyme with with the identifier of the popup for that is used to pass information to.
The information passed doesn't just stop there, it also goes to a popup form which is a javascript function; and this javascript popup form is an initialization of payment gateway where the identifier has already been set.
Adding runat="server" to the <input> tag was a mistake.
"Perhaps load a hidden field with the value and use JavaScript to add the value to the input tag." How is this done please?
Adding runat="server" to the <input> tag was a mistake.
"Perhaps load a hidden field with the value and use JavaScript to add the value to the input tag." How is this done please?
If you want to set the text displayed in the input, then you can use the value attribute.
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Using identifier as userid, the gateway javascript doesn't load. If I change the id to "email-address" without passing any information to it; and the information is inserted manually into the <input> tag, the javascript loads (opens up payment gateway javascript)
Using identifier as userid, the gateway javascript doesn't load.
Is there any error message? Please show me your javascript code.
Best regards,
Sam
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
When the deposit button is clicked, it redirects to the payment page where payment data is required before loading the payment gateway javascript portal for payment. The code is shown below
(It is a Paystack payment gateway):
PaymentPage.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Payment</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<form id="paymentForm" runat="server">
<div class="container">
<h2>Modal Example</h2>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<script src="https://js.paystack.co/v1/inline.js"></script>
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" id="email-address" required />
<br />
</div>
<div class="form-group">
<label for="amount">Amount</label>
<input type="tel" id="amount" required />
<br />
</div>
<div class="form-group">
<label for="first-name">First Name</label>
<input type="text" id="first-name" />
<br />
</div>
<div class="form-group">
<label for="last-name">Last Name</label>
<input type="text" id="last-name" />
<br />
</div>
<div class="form-submit">
<button type="submit">Pay </button>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</form>
<script>
var paymentForm = document.getElementById('paymentForm');
paymentForm.addEventListener("submit", payWithPaystack, false);
function payWithPaystack() {
var handler = PaystackPop.setup({
key: 'pk_live_8971529205020dd307b6f5f4cec944c62712066d', // Replace with your public key
email: document.getElementById("email-address").value,
amount: document.getElementById("amount").value * 100,
firstname: document.getElementById("first-name").value,
lastname: document.getElementById("first-name").value,
ref: '' + Math.floor((Math.random() * 1000000000) + 1), // generates a pseudo-unique reference. Please replace with a reference you generated. Or remove the line entirely so our API will generate one for you
// label: "Optional string that replaces customer email"
onClose: function () {
alert('Window closed.');
},
callback: function (response) {
var message = 'Payment complete! Reference: ' + response.reference;
alert(message);
}
});
handler.openIframe();
}
</script>
</body>
</html>
From the above codes, when the “deposit” button on the home web form is clicked, it redirects to the payment page, then the user ID is expected to be passed from the home web form (“user ID label”) into the <input> tag highlighted in the yellow area. The
issue is that if I change the id of the input tag to “user” in order to pass the information; it passes the information, but the payment portal
(in javascript) will not load because the IDs don't match. But when the <input> tag have the same ID as the “email ID” on the javascript (as shown in the red highlighted area), it loads. This means that on the <input >tag, the email information which
is the user’s ID will be inputted manually. But I would prefer to pass user ID into the input tag in order to help user’s not to mistakenly input another email address.
when the “deposit” button on the home web form is clicked, it redirects to the payment page, then the user ID is expected to be passed from the home web form (“user ID label”) into the <input> tag highlighted in the yellow area
What method did you use to pass the user ID?
georgeakpan233
The issue is that if I change the id of the input tag to “user” in order to pass the information; it passes the information, but the payment portal
(in javascript) will not load because the IDs don't match. But when the <input> tag have the same ID as the “email ID” on the javascript (as shown in the red highlighted area), it loads.
You changed the id in the <input> tag, do you also change it in javascript?
Best regards,
Sam
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
In your code behind, you use "userid" to bind value to the input tag, but in the input tag, your id is "email-address".
Sorry about that; I was supposed to send the method from the test project but I mistakenly sent the the one from the main project.
In the code behind, when the ID is changed to email-address, the ID "email-address is not a recognized identifier due to the "-", and it will return an error.
Here is the method used in the test project and the <inpu> tag, both with the same ID
userid.Text = Session["user"].ToString();
<input type="email" id="userid" required />
May I please ask if you did change the ID in the java and it worked in your computer?
May I please ask if you did change the ID in the java and it worked in your computer?
georgeakpan233
document.getElementById("email-address").value,
I haven't tested all your code, but you can get the value of the input through this method.
document.getElementById("userid").value,
So I suggest you use F12 to debug your js code to see if payWithPaystack is triggered and if there is an error message in the console.
Best regards,
Sam
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
66 Points
175 Posts
Passing Information from user session
May 30, 2020 09:41 PM|georgeakpan233|LINK
I have two webforms (Default1.aspx and Default2.aspx). The Default.aspx has a label that represents login ID, and on the Default2.aspx, there is an input box like this
Default.aspx
Default2.aspx
<input type="email" runat="server" id="email-address" required />
And I want to pass information from user session into the input box in Default2.aspx. I don’t know if it can be done though, but I used this;
The yellow highlighted area is used as the input ID because the javascript event which i am using from an external gateway has "email-address" fixed as the ID as shown below. So i want to pass information into the input having the same ID as the input, because having a different ID from the above input will not load the script.
Default2(Code behind)
May i please what should be done to achieve the goal?
Participant
1253 Points
943 Posts
Re: Passing Information from user session
May 31, 2020 02:55 PM|yogyogi|LINK
You can have same Id of controls as long as controls are in different pages. Session data can be easily shown in these controls.
What errors you are getting in achieving this??
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Member
66 Points
175 Posts
Re: Passing Information from user session
May 31, 2020 03:14 PM|georgeakpan233|LINK
Here is my .aspx web form code
<div class="container-fluid"> <div class="content"> <div class="header"> <h4 class="title">Payment Page</h4> </div> <div class=""> <script src="https://js.paystack.co/v1/inline.js"></script> <div class="form-group"> <label for="email">Email Address</label> <input type="email" runat="server" id="email-address" required /> <br /> </div> <div class="form-group"> <label for="amount">Amount</label> <input type="tel" id="amount" required /> <br /> </div> <div class="form-group"> <label for="first-name">First Name</label> <input type="text" id="first-name" /> <br /> </div> <div class="form-group"> <label for="last-name">Last Name</label> <input type="text" id="last-name" /> <br /> </div> <div class="form-submit"> <button type="button" id="Button1" runat="server" class="btn btn-primary navbar-btn" onclick="payWithPaystack()">Deposit</button> </div> </div> </div> </div>
The yellow highlighted area is the input box with identifier as email-address. Then this is what I used in the server side code (code behind)
Then I am getting this error:
'email-address' is not a valid identifier.
below is a link to the error
https://imgur.com/Elf027m
Participant
1253 Points
943 Posts
Re: Passing Information from user session
May 31, 2020 06:37 PM|yogyogi|LINK
You have to change the name to something like 'emailAddress' because such names having '-' between then is not valid.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠
Contributor
6041 Points
2510 Posts
Re: Passing Information from user session
May 31, 2020 06:43 PM|KathyW|LINK
'email-address' is not a valid identifier.
From https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.control.id?redirectedfrom=MSDN&view=netframework-4.8#System_Web_UI_Control_ID
"Only combinations of alphanumeric characters and the underscore character ( _ ) are valid values for this property. Including spaces or other invalid characters will cause an ASP.NET page parser error."
You won't be able to use that ID, even though you added runat="server" to the <input> tag. You need to re-think your design. Perhaps load a hidden field with the value and use JavaScript to add the value to the input tag.
Member
66 Points
175 Posts
Re: Passing Information from user session
May 31, 2020 07:08 PM|georgeakpan233|LINK
The information passed doesn't just stop there, it also goes to a popup form which is a javascript function; and this javascript popup form is an initialization of payment gateway where the identifier has already been set.
Member
66 Points
175 Posts
Re: Passing Information from user session
May 31, 2020 07:11 PM|georgeakpan233|LINK
"Perhaps load a hidden field with the value and use JavaScript to add the value to the input tag." How is this done please?
Contributor
3370 Points
1409 Posts
Re: Passing Information from user session
Jun 01, 2020 05:51 AM|samwu|LINK
Hi georgeakpan233,
If you want to set the text displayed in the input, then you can use the value attribute.
Or you can try to use the TextBox control.
Best regards,
Sam
Member
66 Points
175 Posts
Re: Passing Information from user session
Jun 01, 2020 09:33 AM|georgeakpan233|LINK
Hi Samwu,
Using identifier as userid, the gateway javascript doesn't load. If I change the id to "email-address" without passing any information to it; and the information is inserted manually into the <input> tag, the javascript loads (opens up payment gateway javascript)
Contributor
3370 Points
1409 Posts
Re: Passing Information from user session
Jun 02, 2020 02:50 AM|samwu|LINK
Hi georgeakpan233,
Is there any error message? Please show me your javascript code.
Best regards,
Sam
Member
66 Points
175 Posts
Re: Passing Information from user session
Jun 02, 2020 10:07 AM|georgeakpan233|LINK
Thank you samwu,
On my home web form there is a label that displays user ID as shown below:
Home.aspx
<asp:Label ID="user" runat="server" Font-Size="Medium" Text="" ForeColor="White"></asp:Label>
And a button:
Home.aspx
When the deposit button is clicked, it redirects to the payment page where payment data is required before loading the payment gateway javascript portal for payment. The code is shown below (It is a Paystack payment gateway):
PaymentPage.aspx
From the above codes, when the “deposit” button on the home web form is clicked, it redirects to the payment page, then the user ID is expected to be passed from the home web form (“user ID label”) into the <input> tag highlighted in the yellow area. The issue is that if I change the id of the input tag to “user” in order to pass the information; it passes the information, but the payment portal (in javascript) will not load because the IDs don't match. But when the <input> tag have the same ID as the “email ID” on the javascript (as shown in the red highlighted area), it loads. This means that on the <input >tag, the email information which is the user’s ID will be inputted manually. But I would prefer to pass user ID into the input tag in order to help user’s not to mistakenly input another email address.
Contributor
3370 Points
1409 Posts
Re: Passing Information from user session
Jun 03, 2020 02:13 AM|samwu|LINK
Hi georgeakpan233,
What method did you use to pass the user ID?
You changed the id in the <input> tag, do you also change it in javascript?
Best regards,
Sam
Member
66 Points
175 Posts
Re: Passing Information from user session
Jun 03, 2020 08:19 AM|georgeakpan233|LINK
Hi Samwu,
On the code behind Paymentpage, I used this
Yes I did that too and the java did not load. I dont know if that email-address ID in the java is tied to the gateway.
Contributor
3370 Points
1409 Posts
Re: Passing Information from user session
Jun 04, 2020 02:38 AM|samwu|LINK
Hi georgeakpan233,
In your code behind, you use "userid" to bind value to the input tag, but in the input tag, your id is "email-address".
You can try to use F12 to debug your js code. about how to use F12 - Developer Toolbar you can refer to this link:
https://www.c-sharpcorner.com/UploadFile/francissvk/f12-developer-toolbar-good-rescuer/
Best regards,
Sam
Member
66 Points
175 Posts
Re: Passing Information from user session
Jun 04, 2020 08:13 AM|georgeakpan233|LINK
Hi Samwu,
Sorry about that; I was supposed to send the method from the test project but I mistakenly sent the the one from the main project.
In the code behind, when the ID is changed to email-address, the ID "email-address is not a recognized identifier due to the "-", and it will return an error.
Here is the method used in the test project and the <inpu> tag, both with the same ID
May I please ask if you did change the ID in the java and it worked in your computer?
-George
Contributor
3370 Points
1409 Posts
Re: Passing Information from user session
Jun 05, 2020 03:24 AM|samwu|LINK
Hi georgeakpan233,
I haven't tested all your code, but you can get the value of the input through this method.
So I suggest you use F12 to debug your js code to see if payWithPaystack is triggered and if there is an error message in the console.
Best regards,
Sam