Realex HPP request -custom field - c#

I'm trying to send a custom field to realex to use upon successful response. The field in question is a json array.
[{"InvoiceId":7,"AmountPaid":180,"SucessfulPayment":false}]
The problem I face is upon response the array is truncated to [{. I have this working by base 64 encoding the array but feel its a bit heavy and would rather send the raw json. I'm also concerned there may be a character restriction on the field length's which would get eaten up quick. If there's no restriction on length I'll probably go base 64.
Update
Code as requested.
JSON array passed into request object
[{"InvoiceId":7,"AmountPaid":180,"SucessfulPayment":false}]
realex response returning
[{
Code:
<%# Page Language="C#" AutoEventWireup="true"
CodeBehind="RealexRedirectTestPay.aspx.cs"
Inherits="SmartClubOnline.RedirectTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body onload="document.form.submit();">
<div class="content">
<form name="form"
action="https://hpp.sandbox.realexpayments.com/pay" method="post">
<asp:Literal ID="MERCHANT_ID" runat="server" />
<asp:Literal ID="SECRET_ID" runat="server" />
<asp:Literal ID="CLUB_NAME" runat="server" />
<asp:Literal ID="ORDER_ID" runat="server" />
<asp:Literal ID="CURRENCY_ID" runat="server" />
<asp:Literal ID="CURRENCY" runat="server" />
<asp:Literal ID="AMOUNT" runat="server" />
<asp:Literal ID="TIMESTAMP" runat="server" />
<asp:Literal ID="MEMBER_ID" runat="server" />
<asp:Literal ID="MEMBER_USERNAME" runat="server" />
<asp:Literal ID="MEMBER_EMAIL" runat="server" />
<asp:Literal ID="INVOICE_ID" runat="server" />
<asp:Literal ID="MEMBERPURSEID" runat="server" />
<asp:Literal ID="SHA1HASH" runat="server" />
<asp:Literal ID="TempOrderNumber" runat="server" />
<asp:Literal ID="PromoRow" runat="server" />
<asp:Literal ID="DELAYEDSETTLEMENTON" runat="server" />
<asp:Literal ID="CREDITCARD_SHG_AMT" runat="server" />
<asp:Literal ID="DEBITCARD_SHG_AMT" runat="server" />
<asp:Literal ID="AUTO_SETTLE_FLAG" runat="server" />
<asp:Literal ID="MERCHANT_RESPONSE_URL" runat="server" />
<!--<input type="hidden" name="AUTO_SETTLE_FLAG" value="1" />-->
<h3>
Redirecting you to our Payment Provider</h3>
<p>
You are being securely redirected to our payment provider...Please Wait...</p>
<!-- uncomment if you want the user to click a button to continue. Also remove the onload function in the Body tag -->
<!-- <p><input type="submit" name="submit" value="continue to payment provider" /></p> -->
</form>
</div>
</body>
</html>
Server side request:
MERCHANT_ID.Text = "<input type=\"hidden\" name=\"MERCHANT_ID\"
value=\"" + merchantID + "\" />";
SECRET_ID.Text = "<input type=\"hidden\" name=\"SECRET_ID\"
value=\"" + sharedSecret + "\" />";
CLUB_NAME.Text = "<input type=\"hidden\" name=\"CLUB_NAME\"
value=\"" + CLUBNAME + "\" />";
ORDER_ID.Text = "<input type=\"hidden\" name=\"ORDER_ID\"
value=\"" + orderID + "\" />";
CURRENCY.Text = "<input type=\"hidden\" name=\"CURRENCY\"
value=\"" + currencyCode + "\" />";
CURRENCY_ID.Text = "<input type=\"hidden\" name=\"CURRENCY_ID\"
value=\"" + currencyCode + "\" />";
AMOUNT.Text = "<input type=\"hidden\" name=\"AMOUNT\" value=\""
+ amount + "\" />";
TIMESTAMP.Text = "<input type=\"hidden\" name=\"TIMESTAMP\"
value=\"" + timestamp + "\" />";
MEMBER_ID.Text = "<input type=\"hidden\" name=\"MEMBER_ID\"
value=\"" + MEMBERID + "\" />";
MEMBER_USERNAME.Text = "<input type=\"hidden\"
name=\"MEMBER_USERNAME\" value=\"" + MEMBERUSERNAME + "\" />";
MEMBER_EMAIL.Text = "<input type=\"hidden\"
name=\"MEMBER_EMAIL\" value=\"" + MEMBEREMAIL + "\" />";
INVOICE_ID.Text = "<input type=\"hidden\" name=\"INVOICE_ID\"
value=\"" + INVOICEID + "\" />";
MEMBERPURSEID.Text = "<input type=\"hidden\"
name=\"MEMBERPURSEID\" value=\"" + "0" + "\" />";
SHA1HASH.Text = "<input type=\"hidden\" name=\"SHA1HASH\"
value=\"" + hash + "\" />";
AUTO_SETTLE_FLAG.Text = "<input type=\"hidden\"
name=\"AUTO_SETTLE_FLAG\" value=\"" + AUTOSETTLEFLAG + "\" />";
DELAYEDSETTLEMENTON.Text = "<input type=\"hidden\"
name=\"DELAYEDSETTLEMENTON\" value=\"" + DELAYEDSETTLEFLAG + "\" />";
CREDITCARD_SHG_AMT.Text = "<input type=\"hidden\"
name=\"CREDITCARD_SHG_AMT\" value=\"" + CREDITCARD_SHG + "\" />";
DEBITCARD_SHG_AMT.Text = "<input type=\"hidden\"
name=\"DEBITCARD_SHG_AMT\" value=\"" + DEBITCARD_SHG + "\" />";
MERCHANT_RESPONSE_URL.Text = "<input type=\"hidden\"
name=\"MERCHANT_RESPONSE_URL\" value=\"" + _realexResponseURL + "\" />";
Failing code in realex response:
if (Request.Form["INVOICE_ID"] != null)
INVOICEID = Request.Form["INVOICE_ID"].ToString();
else
StaticOps.AddErrorToLog("FORM.INVOICE_ID : ", "VALUE NULL",
"RealexResponse");

Apologies for the delay in getting back to you, didn't see the notification of your response. On the POST in, the HPP won't accept the inverted commas and truncates at that point in the string.
Could you try url encoding the string on the way out and decoding when the response comes back? The max length of a custom field on the HPP is 255. Or you could just url encode the inverted commas. Hopefully that suits your needs. Please let me know if not.
Best,
Seán MacDomhnall
Realex Payments

Related

Create HTML table row dynamically with c#

I want to add a row in HTML table with C# method, I have written the code but after execution the row appears at the top of the page not under HTML table.
<tr>
<th></th>
<th>ID</th>
<th>Date</th>
<th>Plot No.</th>
<th>Area</th>
<th>Location</th>
<th>Phase/Division</th>
<th>Remarks</th>
<th>Documents</th>
</tr>
public void AddRow() {
string html = "<tr>" +
"</td> <td class=\"text-right\"><a href = \"javascript:void(0)\" ><i class=\"fa fa-pencil\" ></i></a> </td>" +
"<td><p>1</p></td>" +
"<td><input type = \"date\" runat=\"server\" style=\"width:140px\" /></td>" +
"<td><input type =\"text\" runat=\"serve\"' style=\"width:100px\" /></td><td>" +
"<input type = \"text\" runat=\"server\" style=\"width:100px\"/></td>" +
"<td><input type = \"text\" Value=\"Test2\" runat=\"server\"/></td>" +
"<td><input type = \"text\" runat=\"server\" style=\"width:100px\"/></td>" +
"<td><input type = \"text\" runat=\"server\" style=\"height:50px\"/></td><td>" +
"<input type = \"file\" runat=\"server\" style=\"height:50px\"/></td></tr>";
Response.Write(html);
}
and calling this function from <a> tag in the table.
<td>
<a href="#" runat="server" onserverclick="Unnamed_ServerClick">
<i class="fa fa-pencil" runat="server"></i>
</a>
</td>
and it appears on the top like this.Result
Take a look on the TagBuilder:
https://learn.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/views/using-the-tagbuilder-class-to-build-html-helpers-cs

Remove Span tag generated in asp.net text label

I cannot remove the span tag which auto generated with the image tag.
Asp.net Code :
if (!IsPostBack)
{
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
SiteManagementService siteMng = new SiteManagementService();
LogedUserDTO logedUser = siteMng.GetLogedUserByUserId(Session["UserLoginID"].ToString().Trim());
LabelUser.Text = logedUser.FullName + " | " + logedUser.Company.CompanyDesc;
**LabelImage.Text = "<img src=\"" + siteMng.GetUserImageUrl() + logedUser.ProfileImage + "\" class='img-avatar' />";**
LabelDatetime.Text = DateTime.Now.ToString();
Session["UserAccessLevel"] = logedUser.UserGroupId;
Session["UserCompanyId"] = logedUser.CompanyId;
RepeaterMenu.DataSource = siteMng.GetMenuByUserGroup(logedUser.UserGroupId);
RepeaterMenu.DataBind();
LabelMasterFooter.Text = "© 2013 " + ResourceData.CompanyName + ". All rights reserved.";
}
Front End Code :
<asp:Label ID="LabelImage" runat="server" ></asp:Label>
Generated HTML Code :
<span id="ContentPlaceHolderHeader_LabelImage"><img src="UploadedFiles/ProPicturs/Img_1711.JPG" class="img-avatar"></span>
Code i want is just
<img src="UploadedFiles/ProPicturs/Img_1711.JPG" class="img-avatar">
If you want to only use an image tag, there is an Image tag in asp.net
protected string image_tag; // add this var in your page class and set it as protected
...
if (!IsPostBack)
{
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
SiteManagementService siteMng = new SiteManagementService();
LogedUserDTO logedUser = siteMng.GetLogedUserByUserId(Session["UserLoginID"].ToString().Trim());
LabelUser.Text = logedUser.FullName + " | " + logedUser.Company.CompanyDesc;
image_tag = "<img src=\"" + siteMng.GetUserImageUrl() + logedUser.ProfileImage + "\" class='img-avatar' />";
LabelDatetime.Text = DateTime.Now.ToString();
Session["UserAccessLevel"] = logedUser.UserGroupId;
Session["UserCompanyId"] = logedUser.CompanyId;
RepeaterMenu.DataSource = siteMng.GetMenuByUserGroup(logedUser.UserGroupId);
RepeaterMenu.DataBind();
LabelMasterFooter.Text = "© 2013 " + ResourceData.CompanyName + ". All rights reserved.";
}
you can try to use in .aspx page.
<%= image_tag %>
instead of
<asp:Label ID="LabelImage" runat="server" ></asp:Label>
A Label Control will add a HTML element to the page. Either as a div or a span element. So this
<asp:Label ID="Label1" runat="server" CssClass="MyLabel">
Content...
</asp:Label>
Becomes this
<span id="Label1" class="MyLabel">
Content...
</span>
But a PlaceHolder does not generate it's own html element. So the following code
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
Content...
</asp:PlaceHolder>
Will generate
Content...
But there are some downsides, as a PlaceHolder does not have a CssClass property.

How can you set a lot of text to a property in code only without embedding as a resource?

Suppose I wanted to directly set myCustomHtmlPanel.Text to
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Top navbar example for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="navbar-top.css" rel="stylesheet">
</head>
<body>
<div class="collapse" id="navbar-header">
<div class="container-fluid bg-inverse p-a-1">
<h3>Collapsed content</h3>
<p>Toggleable via the navbar brand.</p>
</div>
</div>
<div class="navbar navbar-light bg-faded navbar-static-top m-b-1">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-header">
☰
</button>
</div>
<div class="container">
<div class="jumbotron">
<h1>Navbar example</h1>
<p class="lead">This example is a quick exercise to illustrate how the top-aligned navbar works. As you scroll, this navbar remains in its original position and moves with the rest of the page.</p>
<a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs »</a>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" integrity="sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js" integrity="sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB" crossorigin="anonymous"></script>
<script src="../../dist/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
Without embedding it as a resource, or doing stuff like :
myCustomHtmlPanel.Text =
"<!DOCTYPE html>"
+ "<html lang=\"en\">"
+ " <head>"
+ " <meta charset=\"utf-8\">"
+ " <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"
+ " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">"
+ " <meta name=\"description\" content=\"\">"
+ " <meta name=\"author\" content=\"\">"
+ " <link rel=\"icon\" href=\"../../favicon.ico\">"
+ ""
+ " <title>Top navbar example for Bootstrap</title>"
+ ""
+ " <!-- Bootstrap core CSS -->"
+ " <link href=\"../../dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
+ ""
+ " <!-- Custom styles for this template -->"
+ " <link href=\"navbar-top.css\" rel=\"stylesheet\">"
+ " </head>"
+ ""
+ " <body>"
+ ""
+ " <div class=\"collapse\" id=\"navbar-header\">"
+ " <div class=\"container-fluid bg-inverse p-a-1\">"
+ " <h3>Collapsed content</h3>"
+ " <p>Toggleable via the navbar brand.</p>"
+ " </div>"
+ " </div>"
+ " <div class=\"navbar navbar-light bg-faded navbar-static-top m-b-1\">"
+ " <button class=\"navbar-toggler\" type=\"button\" data-toggle=\"collapse\" data-target=\"#navbar-header\">"
+ " ☰"
+ " </button>"
+ " </div>"
+ ""
+ " <div class=\"container\">"
+ " <div class=\"jumbotron\">"
+ " <h1>Navbar example</h1>"
+ " <p class=\"lead\">This example is a quick exercise to illustrate how the top-aligned navbar works. As you scroll, this navbar remains in its original position and moves with the rest of the page.</p>"
+ " <a class=\"btn btn-lg btn-primary\" href=\"../../components/#navbar\" role=\"button\">View navbar docs »</a>"
+ " </div>"
+ " </div>"
+ ""
+ ""
+ " <!-- Bootstrap core JavaScript"
+ " ================================================== -->"
+ " <!-- Placed at the end of the document so the pages load faster -->"
+ " <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js\" integrity=\"sha384-THPy051/pYDQGanwU6poAc/hOdQxjnOEXzbT+OuUAFqNqFjL+4IGLBgCJC3ZOShY\" crossorigin=\"anonymous\"></script>"
+ " <script>window.jQuery || document.write('<script src=\"../../assets/js/vendor/jquery.min.js\"><\/script>')</script>"
+ " <script src=\"https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js\" integrity=\"sha384-Plbmg8JY28KFelvJVai01l8WyZzrYWG825m+cZ0eDDS1f7d/js6ikvy1+X+guPIB\" crossorigin=\"anonymous\"></script>"
+ " <script src=\"../../dist/js/bootstrap.min.js\"></script>"
+ " <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->"
+ " <script src=\"../../assets/js/ie10-viewport-bug-workaround.js\"></script>"
+ " </body>"
+ "</html>";
which mangles the code with all sorts of escape values, and such
Or other 'tricks' like :
Saving as a resource, and loading from resources
Loading from an external file / website / database
How can I embed a large block of text as is in my code for the purpose of setting it as a property value or other form of manipulation ?
In other languages, they have identifiers for direct inline inclusion while retaining/permitting the ability to work with the data from a variable. See heredoc and nowdoc
It sounds like you're talking about a verbatim string literal. If you put the # symbol just before the opening quote, it'll allow line breaks and ignore escape characters. You can still use double quotes by repeating the character twice.

How to add runat=server attribute to html buttons

I have multiple html buttons that generated from server side with a method on a csharp class.
the result is:
<button ID='btn1' runat='server' onserverclick='btn_Click'>Apply</button>
<button ID='btn2' runat='server' onserverclick='btn_Click'>Apply</button>
<button ID='btn3' runat='server' onserverclick='btn_Click'>Apply</button>
...
<button ID='btnN' runat='server' onserverclick='btn_Click'>Apply</button>
I also add btn_Click event to behind code:
protected void btn_Click (object sender, EventArgs e)
{
string id = (sender as Control).ClientID;
msg = id;
}
as you can see I want to get buttonId but when I click on any of buttons, btn_Click won't call and I can't get buttonId.
I am using asp.net website with c#4.0.
The problem is I need generate buttons using server side and runat attribute doesn't work with my method . how can I fix this problem?
this is my method body for generated buttons
for (int i = 0; i < dt.Rows.Count; i++)
{
DateTime dtTemp = DateTime.Parse(dt.Rows[i]["messageDate"].ToString());
if (dt.Rows[i]["isRead"].ToString() == "True")
readed = "MessageReaded";
else
readed = "MessageNew";
post += "<div class='modal fade' id='myModal" + dt.Rows[i]["messageId"].ToString() + "' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>"
+ "<div class='modal-dialog' role='document'>"
+ "<div class='modal-content'>"
+ "<div class='modal-header'><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button><h4 class='modal-title' id='myModalLabel'><span style='font-weight:bold'>subject</span> : " + dt.Rows[i]["subject"].ToString() + "</h4></div>"
+ "<div class='modal-header'><p><span style='font-weight:bold'>date</span> : " + dtTemp.ToString("yyyy/MM/dd") + "</p>"
+ "<p><span style='font-weight:bold'>Time</span> : " + dt.Rows[i]["messageTime"].ToString() + "</p>"
+ "<p><span style='font-weight:bold'>email</span> : " + dt.Rows[i]["email"].ToString() + "</p></div>"
+ "<div class='modal-body'>" + dt.Rows[i]["message"].ToString() + "</div>"
+ "<div class='modal-footer'><button type='button' class='btn btn-default' data-dismiss='modal'>close</button>"
+ "<button ID='btn" + dt.Rows[i]["messageId"].ToString() + "' class='btn btn-danger' onclick='DeleteMessage_Click'>Delete</button></div>"
+ "</div></div></div>";
string narrow = Special.TimeToNarrow(dt.Rows[i]["messageDate"].ToString(), dt.Rows[i]["messageTime"].ToString());
post += "<a data-toggle='modal' data-target='#myModal" + dt.Rows[i]["messageId"].ToString() + "' href='#' class='list-group-item " + readed + "'><span class='badge'>" + narrow + "</span><i class='fa fa-fw fa-comment'></i> <span>"
+ dt.Rows[i]["name"].ToString() + "</span> : <span>" + dt.Rows[i]["subject"].ToString() + "</span></a>";
}
So the problem is on
<button ID='btn" + dt.Rows[i]["messageId"].ToString() + "' runat='server' class='btn btn-danger' onserverclick='DeleteMessage_Click'>Delete</button>
EDIT MY POST : As you can see I can't use asp:button because using bootstrap modal. If you think that I can still use asp:button please write your code and show me how .thanks
As other's have said, the problem is ASP.NET won't recognise runat="server" when you generate your controls as a string of HTML.
Your code should probably be done in a much different way, but if you wanted a change to what you have already done that will work you could do this a little differently.
Instead of runat="server" on your buttons, make them submit buttons and assign them a name and value, for example...
Instead of this:
<button ID='btn1' runat='server' onserverclick='btn_Click'>Apply</button>
<button ID='btn2' runat='server' onserverclick='btn_Click'>Apply</button>
<button ID='btn3' runat='server' onserverclick='btn_Click'>Apply</button>
Do this (note they all have the same name):
<button name="btn" type="submit" value="1">Apply</button>
<button name="btn" type="submit" value="2">Apply</button>
<button name="btn" type="submit" value="3">Apply</button>
Then in your Page_Load event you can detect if one of these buttons was clicked with the following:
if (Page.IsPostBack)
{
if (Request.Form["btn"] != null)
{
//A btn was clicked, get it's value
int btn = int.Parse(Request.Form["btn"]);
//Do something with this btn number
}
}
Here's a little sample that has three buttons and displays the number of the button that was clicked:
Test.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<button name="btn" type="submit" value="1">Apply</button>
<button name="btn" type="submit" value="2">Apply</button>
<button name="btn" type="submit" value="3">Apply</button>
</form>
</body>
</html>
test.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
if (Request.Form["btn"] != null)
{
int btn = int.Parse(Request.Form["btn"]);
Response.Write(btn);
}
}
}
}
There's no onserverclick in asp.
You should add the asp:Button tag instead of just Button and instead of onserverclick just OnClick
Something like:
<asp:Button ID='btn1' runat='server' Text="Apply" OnClick='btn_Click'/>
EDIT
The button generation method should look like this:
for (int i = 0; i < dt.Rows.Count; i++){
<div class='modal fade' id='myModal" + dt.Rows[i]["Id"].ToString() + "' tabindex='-1' role='dialog' aria-labelledby='myModalLabel'>
<div class='modal-dialog' role='document'>
<div class='modal-content'>
<div class='modal-header'><button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×</span></button><h4 class='modal-title' id='myModalLabel'><span style='font-weight:bold'>subject</span> :subject</h4></div>
<div class='modal-header'><p><span style='font-weight:bold'>Date</span> : yyyy/MM/dd</p>
<p><span style='font-weight:bold'>Time</span>messageTime</p>
<p><span style='font-weight:bold'>Email</span>email</p>
</div>
<div class='modal-body'>message</div>
<div class='modal-footer'>
<button type='button' class='btn btn-default' data-dismiss='modal'>close</button>
<asp:Button ID='btn" + dt.Rows[i]["messageId"].ToString() + "' runat='server' class='btn btn-danger' OnClick='DeleteMessage_Click'>Delete</button>
</div>
</div>
</div>
You can see that on this line: <button ID='btn" + dt.Rows[i]["messageId"].ToString() + "' runat='server' class='btn btn-danger' onserverclick='DeleteMessage_Click'>Delete</button> i have changed the button with asp:Button and the onserverclick with OnClick.
The previous comments are correct, there is no onserverclick in asp.net server control. onserverclick is available for html controls only.
Below code piece does the job;
protected void btn1_ServerClick(object sender, EventArgs e)
{
HtmlButton btn = (HtmlButton)sender;
btn.InnerText = btn.ID;
}
Cast the sender to HtmlButton to access the ID. You have to use the namespace 'System.Web.UI.HtmlControls'.
EDIT:
If the buttons are being dynamically generated then better to use server button control;
<asp:Button ID="btnAddUser" runat="server" Text="Add" OnClick="btnAddUser_Click" />

Sending my parameters to the other side

Sorry if there are typos or inc clay error when I'm incredibly bad at English.
It is such that I need to send some value over the epay to receive my payment on my website.
onto hh.aspx looks like this:
<asp:Literal ID="LiteralDKK" runat="server"></asp:Literal>
<asp:Literal ID="LiteralPris" runat="server"></asp:Literal>
<asp:Literal ID="Literalwindowstate" runat="server"></asp:Literal>
<asp:Literal ID="LiteralOrderid" runat="server"></asp:Literal>
<asp:Literal ID="Literalmerchantnumber" runat="server"></asp:Literal>
on hh.aspx.cs
string dkk = "DKK";
string windowstate = "3";
string merchantnumber = "1111111";
string prisen = "10";
string ordernr = "159sg";
LiteralDKK.Text = "<input id=\"HiddenPris\" type=\"hidden\" name=\"currency\" value=\"" + dkk + "\" />";
Literalmerchantnumber.Text = "<input id=\"Hiddenmerchantnumber\" type=\"hidden\" name=\"merchantnumber\" value=\"" + merchantnumber + "\" />";
Literalwindowstate.Text = "<input id=\"Hiddenwindowstate\" type=\"hidden\" name=\"windowstate\" value=\"" + windowstate + "\" />";
LiteralPris.Text = "<input id=\"HiddenPris\" type=\"hidden\" name=\"amount\" value=\"" + prisen + "\" />";
LiteralOrderid.Text = "<input id=\"HiddenOrderid\" type=\"hidden\" name=\"orderid\" value=\"" + ordernr + "\" />";
//It must send my value onto this here page
Response.Redirect("https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx");
My parameters which I would like to have sent to you can see how to appear here
If I had to do it in html, it looked like this,
<form action="https://ssl.ditonlinebetalingssystem.dk/integration/ewindow/Default.aspx" method="post">
<input name="merchantnumber" value="ENTER YOUR MERCHANT NUMBER HERE">
<input name="amount" value="10495"> <input name="currency" value="DKK">
<input name="windowstate" value="3"> <input type="submit" value=
"Go to payment">
</form>
The reason I do not do it is to secure me the right price and ordernr and many other things which must cross in.
The documentation here seems to provide simple ways to do this:
http://tech.epay.dk/da/betalingsvindue-integration
In English:
http://tech.epay.dk/en/payment-window-integration

Categories