Unable to call server side method in asp.net - html

I am working in asp.net. I have this HTML tag
HTML tag:
<button id="submit" class="button" onserverclick="delete_Click">Login</button>
Serverside Function:
Response.Redirect("Login.aspx");
When I click the button it should go to Login.aspx page. But button is not working. Where am I mistaking?

Use OnClick instead of onserverclick and better to use ASP.NET control if you are achieving this
<asp:Button ID="submit" runat="server" CssClass="button" OnClick="delete_Click">Login</asp:Button>

You need to add:
runat="server"
to the html tag.
Also, you need to make use of the OnClick event handler.
In essence, you tag should look like this:
<asp:Button ID="submit" runat="server" class="button" OnClick="delete_Click">Delete</asp:Button>
Hope this helps!!!

Related

Using Special HTML symbols inside ASP Button Controller

I would like to display an arrow inside an ASP Button Controller.
The arrow will display perfectly if I used an HTML button.
<button>&#x25B2</button>
I know it works because I can insert HTML tags inside <button>. But the same will not work with an ASP Button.
<asp:Button ID="Button1" runat="server" Text="&#x25B2" />
Is there any way to display an arrow inside the ASP button?
I'm pretty sure you just need a delimiter (;) at the end of the special character:
<asp:Button ID="Button1" runat="server" Text="▲" />
or try
<asp:Button ID="Button1" runat="server">▲</asp:Button>

Navigation from a HTML file into another

I have 2 html files in my desktop(login.html & firstpage.html). I have a button in login.html. when i pressed that button i need to navigate to firstpage.html screen.
I have tried like below; I wrote this in login.html page, But it's not working,
<form name="myform">
<input type="button" value="Enter" width="100px" onclick="<a href ='C:\Users\Desktop\firstpage.html'</a>">
</form>
Could anyone please help me to solve this issue.Thanks
Change the code in
<form name="myform" action="firstpage.html">
<input type="submit" value="Enter" width="100px">
</form>
To just link the two files, all you need is to have them in the same folder, and use this line:
<input type="button" value="Enter" width="100px" onclick="document.location='firstpage.html'">
You do not need a form to do this.
Your onclick handler does not need html in it, just the javascript.
You could also do:
Go to page
Make Slight changes in your code like this
</input>
This should work... :)

Submit a form using <a> anchor element, without javascript

How to replace the submit button with a link without using javascript ? is there any way to add the submit attribute to a link ? because the form will not be sent by a simple link without "submit".
<form:form action="/getPage" >
<div class="buttons">
<a class="link" href="">
<img src="icon.png" />
</a>
</div>
</form:form>
I work in an application web so if i use javascript the link will not be mapped by the server ..
You can not submit a form using an <a> tag alone. You will need some type of javascript to assist, if you insist on using the <a> tag:
Submit the Form
or
Submit the Form
or super hack:
Submit the Form, then on backendPage.php you can use $_GET requests to process information, and redirect the visitor to the intended page. But that's a horrible idea haha
Try this:
CSS
button {
background:none!important;
border:none;
padding:0!important;
/*border is optional*/
border-bottom:1px solid #444;
}
HTML
<button>your button that looks like a link</button>
This can achieve the same effort and it looks like <a>
Note: btn btn-link comes from bootstrap
<button class="btn btn-link" type="submit"><img src="icon.png" /></button>
There is an another way out. Using this method you can use any element to submit a form.
Following is an example:
<span onclick="$('#submit').trigger('click')" style="cursor:pointer;">
anything
</span>
Add a hidden submit button:
<input style="display:none;" type="submit" id="submit"/>
This will behave exactly as actual submit button.

Creating a input link button

hello all a quick question..
i am building a static html page, and would like to like one page to another using a button, now using a link is the easier option but i would like the effect of a button without any javascript going off..
so i would like to use a input button but it to link to a html page like an tag can href.
i was thinking along the lines of this example but without the js..
<form>
<input type="button" value="Read more" class="button" onclick="window.location.href='testimonials.html'">
</form>
this doesnt work but i am looking for this functionality?? is it possible?
Just submit the form to the URL.
<form action="testimonials.html">
<input type="submit" value="Read more">
</form>
… but buttons are supposed to do stuff. Links go places. Don't send people mixed messages, use a link.
you've misspelled "onclick" :)
EDIT: if you want to avoid javascript, you can create a button-like link with CSS:
Read More
Try this code:
<form>
<input type="button" value="Read more" class="button" onlick="window.location='testimonials.html'">
</form>

Problem with form buttons in IE

I have buttons on a page that look like:
<p>
<a href="view.php">
<input type="button" name="view" value="View Database" />
</a>
</p>
IE does not support these buttons or multiple buttons I am not sure which one. Does anyone know how to fix this to work with IE?
Embedding a button within an <a> tag is not normally done, and really doesn't make any sense. If you want your link to look like a button, then just use the <input> tag with some script on the onclick event, or use css to make your link look button-ish (start by using display:block or display:inline-block);
You can't put an input into the tag, instead, you can create a form, and change your button to a submit one. Then you can choose the target url in the form, like this:
<form action="view.php">
<input type="submit" name="view" value="View Database" />
</form>
I would recommend this over using javascript, because buttons are not designed for navigating a site. If you want to submit information, which is what they are used for, you won't be able to do it so cleanly using javascript.
What exactly are you trying to achieve? If you want a custom button to redirect to view.php, you can use onclick:
<input type="button" name="view" value="View Database" onclick="window.location.href='view.php';" />
or something similar.
<input type="button"
onclick="javascript:document.location='view.php';"
value="View Database"/>
Try with this ugly monster:
<input type="button" name="view" value="View Database" onclick="javascript:window.location='view.php'"/>