Solved

Display criteria change without refreshing whole page in asp.net

Posted on 2011-02-15
10
493 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now