Solved

Display criteria change without refreshing whole page in asp.net

Posted on 2011-02-15
10
496 Views
Last Modified: 2012-05-11
Hi everyone.

Can anyone help me with the above.

What i am trying to do is have a page that is displayed within another page (<!-- #include-->), however, depending on what they click, i want the page to refresh just the include page with the new criteria, but if the click another part of the included page, it takes them to another page.

Can any help me please

Baker
0
Comment
Question by:Bakersville
10 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 34895760
you need to use iframes

<div class="iframeContainer">
  <iframe src="newPageTobeIncluded.html"/>
<div>
0
 
LVL 1

Author Comment

by:Bakersville
ID: 34895787
Thank you gurvinder372, i really want to keep away from iframes as must of the browsers dont support them.

There really is no way of doing it without?
0
 
LVL 5

Expert Comment

by:_-MYFOX-_
ID: 34895815
The best way to make and keep the code clean (ie without the iframe) is using  ajax ...
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:Bakersville
ID: 34895842
Thank you MYfox.

Can you help me how to do this?

Lets say i have a include page in the middle of the webpage and it is already pointing to default.aspx?pageid=1

Now if you click on a link that then displays default.aspx?pageid=1&mysite=me&do=uk

Thanks
0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 34895919

You might want to consider an ajax solution:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26821974.html</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

jQuery(document).ready( function () {

  $(".dynamic").click( getContent );

});

function getContent( event ) {
  event.preventDefault();
  $("#dynamic-content").load( $(this).attr( "href" ) );
}

</script>

<style>
#dynamic-content { width: 640px; height: 400px; border: 1px dotted #f00; margin-left: auto; margin-right: auto; overflow: scroll; background-color: beige; }
</style>

</head>
<body>

<a href="http://www.whatcar.com/Valuation/SelectMake?makeId=4708" class="dynamic">Alfa Romeo</a> |
<a href="http://www.whatcar.com/valuation/SelectMake?makeId=5202" class="dynamic">Aston Martin</a> |
<a href="http://www.whatcar.com/valuation/SelectMake?makeId=5289" class="dynamic">Audi</a> |
<a href="http://www.whatcar.com/valuation/SelectMake?makeId=28656" class="dynamic">Bentley</a> |
<a href="http://www.whatcar.com/valuation/SelectMake?makeId=6805" class="dynamic">BMW</a>

<div id="dynamic-content"></div>

</body>
</html>

Open in new window

0
 
LVL 5

Accepted Solution

by:
_-MYFOX-_ earned 250 total points
ID: 34896451
0
 
LVL 14

Assisted Solution

by:Dhanasekaran Sengodan
Dhanasekaran Sengodan earned 250 total points
ID: 34896482
0
 
LVL 1

Author Comment

by:Bakersville
ID: 34917698
Hi everyone.

I have been trying to get it to work with very little luck, so spent more time researching and come up with a solution from w3schools, however, i have changed the code but still can not get it to work.

I have my file in asp.net, if quesrystring = me, me1 or me2 then i should display something

If Request.QueryString("q") = "me" Then
            Response.Write("Number 1 selected")
        ElseIf Request.QueryString("q") = "me1" Then
            Response.Write("Number 2 selected")
        ElseIf Request.QueryString("q") = "m2" Then
            Response.Write("Number 3 selected")
        Else
            Response.Write("Nothing selected")
        End If

On the page that this will be displayed i have

<script type="text/javascript">
function showCustomer(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
   
    }
  }
xmlhttp.open("get","menu.aspx?q="+str,true);
    xmlhttp.send();
//
}
</script>

Within the boty i have

<div id="txtHint">Customer info will be listed here...</div>
                <a href="javascript:showCustomer('me')"> 1</a>

However it still does not go of and bring the data back.

Please can anyone help me.

Baker
0
 
LVL 1

Author Comment

by:Bakersville
ID: 34918211
Thank you all, but i now have it working and bring the information accross.

Basically, the above worked, but i was trying to bring accross an entire page and not just the code itself.

Baker
0
 
LVL 1

Author Closing Comment

by:Bakersville
ID: 34918227
Thanks for pointing me in the right direction
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question