No response while pressing on a button from mobile - c#

I have responsive website, while pressing on one of the buttons :
<div class="button">
<input src="Images/TransparenImgButt.PNG"
onclick="if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate('');"
name="ctl00$ContentPlaceHolder2$OrderNewCard" type="image"
id="OrderNewCard" runat="server" class=" NewCardPic"
/>
</div>
I don't get the page I need (which I get from the web) what I need to change here?
Thank you for any help

Related

How to make Checkout button initialize paypal pay form ? ASP.NET Core MVC

I've been searching a solution for this problem and only found that you cannot target paypal buttons with jquery for security reasons.
So I have this form that i need to open my paypal window pay with cards and on success it should fire up an api call that I'll add later
<form onsubmit="openPaypal" style="margin-bottom:30px">
<div class="row heading">
<h5>Checkout information</h5>
</div>
<hr />
<div class="field">
<label>Email:</label>
<div class="price-field">
<span><i class="far fa-envelope"></i></span>
<input required name="email" type="email" value="" />
</div>
</div>
<div class="space"></div>
<div class="field">
<label>Name:</label>
<div class="price-field">
<span><i class="fas fa-user-alt"></i></span>
<input required name="name" type="text" value="" />
</div>
</div>
<div class="space"></div>
<div class="field">
<div id="paypal-button-container"></div>
<button type="submit" class="btn btn-primary">Checkout</button>
</div>
</form>
And I need it to somehow when submitted , to open the paypal pay form.
I copied the paypal buttons solution from their docs
<script src="https://www.paypal.com/sdk/js?client-id=ClientId">
// Replace YOUR_SB_CLIENT_ID with your sandbox client ID
</script>
<!-- Add the checkout buttons, set up the order and approve the order -->
<script>
function openPaypal(event) {
$('.paypal-button-number-1').click();
}
paypal.Buttons({
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
alert('Transaction completed by ' + details.payer.name.given_name);
});
}
}).render('#paypal-button-container'); // Display payment options on your web page
</script>
To be specific , I seek something like sellfy.com's paypal checkout. You enter your credentials in the cart , it makes a validation and then sends you to some paypal web page. There you enter what paypal needs and at the end you have return to merchant, where you get redirected to your website(in that redirect I guess you can call out a method that does the next part of the checkout)
Uhm, so
function openPaypal(event) {
paypal.Buttons({
[..snip..]
}).render('#paypal-button-container');
}
And since you want it to "fire up an API call", you should be creating and capturing the payment on the server side. For that you need this UI button code: https://developer.paypal.com/demo/checkout/#/pattern/server
And two corresponding routes on your server, one for 'Set Up Transaction' and one for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/

How to insert HTML radio button value to SQL through ASP.NET

Please, I'm stuck trying to send my radio button user choice to the aspx.cs file and sent it to SQL, so here's the code:
<div class="form-group">
<label class="control-label col-sm-3">Status</label>
<div class="col-sm-6">
<div class="row" id="row" runat="server">
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" id="nsent" value="nsent" name="status" runat="server" checked="true">Not Sent
</label>
</div>
<div class="col-sm-4">
<label class="radio-inline">
<input type="radio" id="sent" value="sent" name="status" runat="server">Sent
</label>
</div>
</div>
</div>
So after I click Submit, there's a code to send it to SQL, but I don't have any idea how I would send the value selected in the HTML.
Selected Item or Selected Value won't work, even InnerText.
for a radio button, and in WEBFORMS, you would look at both control's CHECK state
if (sent.Checked) == true {...}
if (nsent.Checked == true) {...}
Alternatively you could review the FORMS collection that was submitted with the Page.Request (if this is a POSTBACK).
if (page.request.forms["status"] == "sent") {
...
} elseif (page.request.forms["status"] =="nsent" {
...
}
A third option, which seems to be outside the scope of your question is to read the radio buttons on the client side, and submit the value to the server via some AJAX style submission.
You should use <asp:Checkbox> (ASP.NET WebForms) or #Html.CheckBoxFor() (ASP.NET MVC).

Input submit onclick and onserverclick not working

I'm working on a simple login screen with the below code:
<form id="login">
<div class="formHeader">
<h1>Login</h1>
</div>
<div class="formDiv">
<input type="text" placeholder="Email" name="txtEmail"/>
<div class="inputImage fa fa-user"></div>
</div>
<div class="formDiv">
<input type="password" placeholder="Password" name="txtPassword"/>
<div class="inputImage fa fa-lock"></div>
</div>
<div class="formDiv">
<label id="remember">
<input type="checkbox" name="cbxRemberMe" value="Checked"/>
<div class="checkbox"></div><span>Remember me</span>
</label>
</div>
<div class="formDiv">
<input type="submit" value="LOGIN" onclick="btnLogin_Click" />
</div>
<div class="formFooter"><a class="forgot" href="#">Forgot Password</a></div>
and back-end code
protected void btnLogin_Click(object sender, EventArgs e)
{
}
But the button does not call the backend code at all.
Nothing happens except the URL changes from
"http://localhost:15726/Pages/Login.aspx" to
"http://localhost:15726/Pages/Login.aspx?txtEmail=&txtPassword=&ctl00=LOGIN"
I cannot put a Runat=Server attribute in the form as I have 2 forms on this page (login and register)
any help is appreciated.
What I have tried:
Playing around with Runat=Server, onclick() and OnServerClick() (swapping around and changing them up)
Making input type=submit / input type=button
none of these work.
Have you tried these two approaches?
<asp:Button runat="server" id="btnLogin" Text="LOGIN" OnClick="btnLogin_Click">
or
< button onserverclick="btnLogin_Click" runat="server" id="btnLogin">LOGIN</button>
Edit
This was supposed to be a comment and not answer. Sorry for that.
However, the entire form doesn't seem to be "webform" form compatible. If you want to be able to read the values from the form elements the form should have a runat="server" tag, too.
Firstly, you need to specify whether it is a server control or client control. Specify runat=server to tell that it should be available for the Code-Behind file.
Finally, Use any javascript function with OnClick and any code behind function with OnServerClick
Something like this,
aspx
Plain HTML
<input type="submit" runat="server" value="LOGIN" onclick="return js_btnLogin_Click()" OnServerClick="btnLogin_Click"/>
or with ASPX Control
<asp:Button runat="server" Text="LOGIN" OnClientClick="return js_btnLogin_Click()" OnClick="btnLogin_Click">
javascript
<script type="text/javascript">
function js_btnLogin_Click()
{
//return false, in case if you want to stop posting the form to the server
return true;
}
</script>
Code-Behind
protected void btnLogin_Click(object sender, EventArgs e)
{
}

c# send a keypress to the form only

So I have a form with a webbrowser in it. It needs to put some text into a text field input and then it has to press enter to send the text. But the problem I got is when I am doing something else it tries to press enter in that program I am currently using.
webBrowser1.Document.GetElementById("chatMessage").SetAttribute("Test");
webBrowser1.Select();
webBrowser1.Document.GetElementById("chatMessage").Focus();
System.Windows.Forms.SendKeys.SendWait("{ENTER}");
Any idea on what I should use instead?
Here is the html code.
<form id="chatForm">
<div style="margin:5px">
<div class="form-group" style="margin-bottom:5px">
<input type="text" class="form-control" placeholder="Type here to chat..." id="chatMessage" maxlength="200" autocomplete="off">
</div>
<div class="pull-left">
<strong>Users Online: <span id="isonline">0</span></strong>
</div>
<div class="checkbox pull-right" style="margin:0px">
<label class="noselect">
<input type="checkbox" id="scroll">
<strong>Pause chat</strong>
</label>
</div>
<br>
<div class="pull-left">
Chat Rules
</div>
</div>
</form>
I don't think it is possible. All I could think of is focusing your application for a split second, send the keys and jump back to where you were. But this holds so many errors and will disturb you at least for a little moment that you won't be satisfied with it. Is there no chance for you to send the data/message on a direct way instead of simulating the keyboard input?
Checkout the key hook
C# : Keyboard Hook

C# AJAX Comments in post

Here I made a simple webpage to post pictures, text, etc. I also made a simple ajax file to send the text, picture, etc to the database, and retrieve that information to be displayed in the same webpage. Here is the main webpage:
<div class="here" id="here">
#foreach (var photo in db.Query(photos, galleryInfo)){
<div class="com_1 com_3">
<div class="com_4">
<div class="com_44">
<img alt="miniatura" style="margin-top: 0" src="#Href("~/Photo/Thumbnail2", photo.UserId, new { size="small" })" class="thumbnail-border thumb22" />
<div class="n-s">
<b>#photo.Nombre #photo.Apellido</b>
</div>
</div>
<div class="com_5">
#photo.Comment
</div>
</div>
<div class="comcom">
<div class="comcom1">
<form onsubmit="return fofon(this)" id="gog">
<input type="text" style="display: none" name="GroupId" value="#galleryInfo" />
<textarea class="texta"name="comment" placeholder="Write a comment..."></textarea>
<input type="submit" class="g_sub"/>
</form>
</div>
</div>
</div>
}
In case it gets confuse, this shows every post with a "comment section" below each one (we can call them "Commne2"). The ajax will get the text, picture etc, send it to the database, and post it to another file, which will be displayed here... in the #foreach{}.
Obviously, the posts do not "excist", so any javascript that affects that post, will not work, because that element does not exciste in this case.
So my problem is, how can I create an ajax file (javascript file) that affects the Comment2 so that I can comment a post?

Categories