Stop page refresh on Image Button Click - html

This is the code what i tried:
<asp:ImageButton ID="imgDropArrow" class="cssDropArrow" ImageUrl="~/Styles/Down.gif" OnClick="ImageDropArrow_Click" runat="server"/>
Everytime I click on this imagebutton, page refreshes.
What I want on click is to run the serverside("ImageDropArrow_Click") function and no page refresh.
Any help will be highly appreciated.

I suggest to use UpdatePanel in Your Code
for example
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!--Content Here-->
<asp:ImageButton ID="imgDropArrow" class="cssDropArrow" ImageUrl="~/Styles/Down.gif" OnClick="ImageDropArrow_Click" runat="server"/>
</ContentTemplate>
</asp:UpdatePanel>
</form>

Look at the following link. It might be helpful for you.
http://www.codeproject.com/Articles/401903/AJAX-for-Beginners-Part-Understanding-ASP-NET-AJ

At first use runat="Server" and you can use updatepanle with imagebutton

Related

How to link css file in vb asp.net project

How to link css file in vb asp.net project
Right now my css file is not beeing run from Home.aspx files. What is my All_Body.css file path that I should type in Home.aspx file.
I need to put this code on server so I can not use full path with my computer username
project Files:
>MyWebsite
>Styles
>All_Body.css
>UI
>Home.aspx
>Master.master
All_Body.css full path
C:\Users\Dave\source\WebSites\MyWebsite\Styles\All_Body.css
Home.aspx
<asp:Content id="Home_Content1" ContentPlaceHolderID="head" runat="server">
<link rel="stylesheet" type="text/css" href="~\Styles\All_Body.css" />
...
</asp:Content>
Master.master
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
...
</body>
</html>
I cleared my browser cache and it worked.
The browser doesn't reload the css or js files, so as a developer you have to do hard refresh /reload every time you update the css or js files and you must add query string like ?v=0.01 after the href or src when you publish the website to the server and change the number every time.
ex:
href="styles.css?v=0.01"
src="main.js?v=0.01"
Now the browser will think this is a new file and will reload it in the client browsers.
Home.aspx
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
....
</asp:Content>
Master.master
The link to your CSS file should be in the <head> element of the master page:
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<link rel="stylesheet" type="text/css" href="Styles/All_Body.css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
</body>
</html>
Note that I updated the path to your CSS file which was incorrect; this link is relative to the root. Also, the "~/" only works when you include runat="server" - either way it is not needed when using a relative link for CSS. You also had a malformed head content placeholder. The content placeholder for the main content was missing from your master page. There was no form tag so nothing could work. In fact the code you presented would not even compile. If you simply used the standard Web Forms template out of the box with the master page option, it would have worked.
Tip: The easiest way to get the CSS link correct in a master page is to drag the CSS file from Solution Explorer into the <head> section of the master page in Visual Studio.

HTML / ASPX pages not validating and not rendering or validating

As a disclaimer, I have read all of the posts regarding this topic and have tried all of the suggestions and still don't seem to be able to get this to work. So, for purposes of this question, I have created a very simple Master page file and an index file. The code for the master page is:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="master.master.cs" Inherits="EckankarInOklahoma.master" %>
<!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>ECKANKAR in Oklahoma</title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
The index page's code is as follows:
<%# Page Title="" Language="C#" MasterPageFile="~/master.Master" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="EckankarInOklahoma.index" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
I DON'T GET THIS AT ALL :)
</asp:Content>
When I debug through Visual Studio, I get the expected white screen that just says:
I DON'T GET THIS AT ALL :)
But after publishing, uploading to the website via ftp and going to the website, I get nothing but my code. I have saved the files with encoding but without BOM. I used Sublime Text editor to ensure I was saving without BOM. I have published and then uploaded, and I have uploaded without publishing. All to no avail. I still get unrendered code.
Additionally, I have tried to validate through W3C Schools and the code will not validate. I have 3 errors and 3 warnings.
Can someone please advise what I might be doing wrong? Thanks in advance. Have a great weekend!
***update 1 = I tried what MarcusVinicius suggested and that did get me closer, but now instead of giving me my code as text, it says :
This is a marker file generated by the precompilation tool, and should not be deleted!
I am unsure of where to go from here. I published the website as not updatable and the config files are in the root directory. Any more ideas for me to try? Again, I appreciate all of the help and suggestions. :)

ASP:Content master page control being called when not in markup?

I'm using an ASP master page to lay out content on my webpage.
The Site.Master file looks something like this.
<div class="container fullwidth-main-content">
<asp:ContentPlaceHolder ID="FullWidthMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="container margin-main-content">
<asp:ContentPlaceHolder ID="MarginMainContent" runat="server">
</asp:ContentPlaceHolder>
</div>
Now.. On my default.aspx I'm calling the <asp:ContentPlaceHolder ID="FullWidthMainContent" control. amongst other content controls.
However on my Portfolio.aspx page for some reason even though I'm not calling the <asp:ContentPlaceHolder ID="FullWidthMainContent" control it's still appearing underneith my other content that I have called.
Why is this happening?

'TextBox' must be placed inside a form tag with runat=server"

hey guys i'm building a website for a school assignment and i want to create a multi line text box but when i do i get the error "'TextBox' must be placed inside a form tag with runat=server" I've looked it over and it wouldn't go away by inserting a form tag with runat server before the text box code. how can i fix this? here's the code:
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
<form id="Form1" runat="server">
<div id="body">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</asp:Content>
Just remove the form tag from your content page - the form tag on the master page will be sufficient. You will need the ContentPlaceHolder tags on the master page to be within the form for this to work.
like
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="bodycontent" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>

Updatepanel and fancybox not working unless fancybox is opened twice

Ok I have a page being pulled through onto the fancybox popup,
(note: the paging works 100% on the page itself),
but when on the fancybox I attempt to page through the repeater and nothing happens.
I then close the popup and reopen it without refreshing the page, and paging now works?
I refresh the page then have to go through the process of opening the popup then trying to page through the repeater then close the popup then reopen it and the paging works again.
Can anyone point me in the right direction as to what maybe causing this? I've already attempted Change the 'body' to 'form' method's.
EDIT: It does manage 1 postback, then it freezes and if reopened works for more then 1 postback.
EDIT: I have found that when the update panel send the request and comes back it creates a secondary __VIEWSTATE object in the updatepanel.
Code for the page being called:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Search.aspx.cs"Inherits="AfricaCentre.Search" EnableEventValidation="false" EnableViewState="false" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<%--<script type="text/javascript" src="<%= ResolveUrl("~/scripts/Scripts.js") %>"></script>--%>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!-- SEARCH -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Hello
<asp:Button Text="Test" runat="server" />
</ContentTemplate>
</asp:UpdatePanel> </form>
</body>
</html>
Code Link button calling the fancybox with script:
<a id="search" href="/Search" class="fancybox.ajax">SEARCH</a>
$("#search").fancybox(
{
type: 'ajax',
autoSize: false,
padding: 0,
width: 800,
height: 567,
scrolling: 'no',
openEffect: 'fade',
openSpeed: 'slow',
transitionIn: "elastic",
transitionOut: "elastic",
autoScale: false,
hideOnContentClick: false,
afterLoad: function () {
}
}
);
I have just used an iframe to resolve my problem.