Hi
apologies as I guess this has been covered on a number of occassions, but I am very much new to web devt and am struggling to patch code snippets on google results on similar sounding queries into my own.

I have been coding a page, which has an iframe, the src of which points to separate aspx pages which call various web methods on a web service that I have put into the project. At the moment each of the child aspx pages has the value of IPMSREF hardcoded into the call tot he webservice - I want to pass a reference number which is specified as a parameter of the URL of the parent page.

The parent page code (Results_Freehold.aspx) looks like:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Results_Freehold.aspx.cs" Inherits="_Default" %>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  


<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
<title>Freehold Related Data</title>  

<link href="COMMON/StyleSheet.css" rel="stylesheet" type="text/css" />  

<script type="text/javascript"></script>  
 </head>  
 <body>  
     <form id="form1" method="post" runat="server">  
     <div>  
      <div class="tabArea">  
     <a class="tab" href="ASP/Acquifree/AcquifreeConditions.aspx" target="myIframe">Conditions</a>  
    <a class="tab" href="ASP/Acquifree/AcquifreeCPO.aspx" target="myIframe">CPO</a>  
    <a class="tab" href="ASP/Acquifree/AcquifreeRectified.aspx" target="myIframe">Rectified</a>  


  </div>  

  <div class="tabMain">  

    <div class="tabIframeWrapper">  

      <iframe class="tabContent" name="myIframe" src="ASP/Acquifree/AcquifreeConditions.aspx" marginheight="8" marginwidth="8" frameborder="0"></iframe>  

     </div>  
   </div>  

 </div>  

 </form>  

</body>  

</html>

If we take the example of the AcquifreeConditions.aspx, the Code for this page:-

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
   
public partial class AcquifreeConditions : System.Web.UI.Page  
{  
    Service ipmslookup = new Service();  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        GridView1.DataSource = ipmslookup.Acquifree_ConditionsFreehold(304747);  
        GridView1.DataBind();  
    }  
}

and the markup:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AcquifreeConditions.aspx.cs" Inherits="AcquifreeConditions" %>  
    

<!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></title>  
</head>  
 <body>  
     <form id="form1" runat="server">  
    <div>  
      
         <asp:GridView ID="GridView1" runat="server">  
        </asp:GridView>  
      
    </div>  
    </form>  
</body>  
</html>

The equivalent Webmethod:-

using System;  
using System.Web;  
using System.Web.Services;  
using System.Web.Services.Protocols;  
using System.Configuration;  
using System.Data;  
using System.Data.OracleClient;  
   
[WebService(Namespace = "http://tempuri.org/")]  
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
public class Service : System.Web.Services.WebService  
{  
    public Service () {  
   
        //Uncomment the following line if using designed components   
        //InitializeComponent();   
    }  

    
[WebMethod(Description = "Get Related Data of Acquifree from Conditions Freehold")]  
   
        public DataSet Acquifree_ConditionsFreehold(int IPMSREF)  
{  
    using (OracleConnection connection = new OracleConnection  
    (ConfigurationManager.ConnectionStrings["IPMS_ADMIN"].ConnectionString))  
    {  
        string Query = "SELECT IPMSREF,TYPCONDN,DESCONDN,DETCONDN,DISPLAYFIELD FROM conditionsFreehold where IPMSREF= " + IPMSREF;  
        OracleCommand command = new OracleCommand(Query, connection);  
        command.CommandType = CommandType.Text;  
        connection.Open();  
        OracleDataReader reader = command.ExecuteReader();  
   
        DataTable myTable = new DataTable("myTable");  
        myTable.Columns.Add("IPMSREF", typeof(int));  
        myTable.Columns.Add("TYPCONDN", typeof(string));  
        myTable.Columns.Add("DESCONDN", typeof(string));  
        myTable.Columns.Add("DETCONDN", typeof(string));  
        myTable.Columns.Add("DISPLAYFIELD", typeof(string));  
  
        while (reader.Read())  
        {  
            myTable.Rows.Add(new object[]   
                 {   
                    reader["IPMSREF"].ToString(),  
                    reader["TYPCONDN"].ToString(),  
                    reader["DESCONDN"].ToString(),  
                    reader["DETCONDN"].ToString(),  
                    reader["DISPLAYFIELD"].ToString()});  
        }  
        //myTable.Load(reader);  
        myTable.AcceptChanges();  
        DataSet ds = new DataSet();  
        ds.Tables.Add(myTable);  
        ds.AcceptChanges();  
        return ds;  
    }  
}

Obviously my example at the moment has the value of IPMSREF hardcoded in the AcquifreeConditions.aspx.cs - I want to pass it in from the parent URL like

/Results_Freehold.aspx?IPMSREF=304747

So that the call to the webservice is variable depending on the value of IPMSREF in URL which calls the parent page. Can anyone give me any pointers?

Thanks Mark

in the Page load event of AcquifreeConditions.aspx.cs
write

using System; 
using System.Collections.Generic;
using System.Linq;  using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AcquifreeConditions : System.Web.UI.Page
  {      Service ipmslookup = new Service();      protected void Page_Load(object sender, EventArgs e)      {          GridView1.DataSource = ipmslookup.Acquifree_ConditionsFreehold(304747);          GridView1.DataBind();      }  }using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
   
public partial class AcquifreeConditions : System.Web.UI.Page  
{  
    Service ipmslookup = new Service();  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (Request.QueryString["IPMSREF"] != null)
        {

        GridView1.DataSource = ipmslookup.Acquifree_ConditionsFreehold( Convert.ToInt32 (Request.QueryString["IPMSREF"].ToString ()));  
        GridView1.DataBind();  
        }
        
    }  
}

Try this,it should solve the matter.

This code simply gets the query string passed from the parent page and sends to the call you made.
If you donot pass a query string ,then it will do nothing,so be sure that you pass something as your IPMSREF from the parent page.

And then call the page like

Results_Freehold.aspx?IPMSREF=304747
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.