473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# WebApp: retreiving a control value in a master page form

econVictim
I have a standard html form in a masterpage that is part of a search engine on a separate page...
Expand|Select|Wrap|Line Numbers
  1. <form id="fsearch" action="search.aspx" method="post">
  2. <table border="0" cellpadding="0" cellspacing="0">
  3. <tr>
  4. <td style="width: 280px;"><input type="text" id="search" style="height:21px; border:solid thin #CCCCCC; float:right;" /></td>
  5. <td style="width: 22px"><input type="image" src="search.png" id="Image1" onclick="searchSubmit()" /></td>
  6. <td style="width:500px; float:right;"><span id="menu"><a href="logout.aspx" accesskey="4" title="">log out</a> <a href="#" accesskey="1" title="">meet</a> <a href="topics.aspx" accesskey="2" title="">discussions</a> <a href="search.aspx" accesskey="3" title="">friends</a> <a href="profile3.aspx?page=1" accesskey="4" title="">profile</a> <a href="main.aspx" accesskey="4" title="">main</a></span></td>
  7. </tr>
  8. </table>
  9. </form>
  10.  
However on the search page I cannot retrieve the value from
Expand|Select|Wrap|Line Numbers
  1. <input type="text" id="search" style="height:21px; border:solid thin #CCCCCC; float:right;" />
  2.  
How can I get the value so that when somebody executes a search from the form on the masterpage that I can execute a function on page load on search.aspx?
Dec 10 '08 #1
7 3653
Frinavale
9,735 Expert Mod 8TB
Use GET instead of POST and pass the search parameters using the URL to the search page.

Alternatively you could move the Search.aspx page into a user control (Search.ascx) and place an instance of that user control onto the MasterPage. Then you could avoid using 2 forums in your aspx page.
Dec 10 '08 #2
frinivale,

thanks.. I have gone ahead and tried to implement the GET method as you have suggested. The results are not what I expect however. When I submit the form I get a bizzare ?x=11&y=7 at the end of the url. X and Y are not variables in this form.

Every thing seems to be working alright, in other standard aspx pages the GET method works just fine...

Any ideas what would cause this?
Dec 10 '08 #3
Frinavale
9,735 Expert Mod 8TB
@econVictim
Sorry I've never seen that happen.....that is strange.
Dec 10 '08 #4
If i do not hear of any other suggestions I will try your second alternative... to me this is extremely bizarre.. Although, it does not surprise me that I have a strange error.

Thank you
Dec 10 '08 #5
I've created the custom control - however using the control destroys my sessions. Is there somethings I'm missing? I've created an ascx.cs and placed the following code inside.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Web.SessionState;
  12.  
  13. public partial class fsearch : System.Web.UI.UserControl
  14. {
  15.     protected void Page_Load(object sender, EventArgs e)
  16.     {
  17.         int userId = Convert.ToInt32(Session["user_id"]);
  18.         Session["user_id"] = userId;
  19.     }
  20. }
  21.  
Dec 17 '08 #6
Frinavale
9,735 Expert Mod 8TB
You are setting:

Session["user_id"] = userId;

Where is userId defined? If it's not, you are effectively setting your Session "user_id" to nothing...which would kill it.

-Frinny
Dec 17 '08 #7
Thank you frinny again for replying to my question. I am now completely confused about my strange errors. I have scoured the internet looking for reasons why this doesn't work. I want to believe that a form with the get method would be the answer, and I think it is the answer. However for the life of me I cannot figure out why my form returns get methods with ?x=somenumber&y=somenumber. I think the numbers returned in the get method are related to the position of the mouse. After removing all scripts and taking the page down to nothing but the form, I sill get the x/y variables. I cannot concieve what would cause this. I'm starting to wonder if it is some IIS issue or something else I would never think of.
Dec 17 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jorge Ayala | last post by:
Well I'm trying to catch and act upon a button event that is placed within the item template of a repeater control. Yet the code I'm using isn't working. What I've seen out there to explain how...
4
by: Ali | last post by:
I used to clear my page's control in Visual Studio 2003 using code like this: Dim c As Control For Each c In Page.Controls(1).Controls If TypeOf c Is TextBox Then CType(c, TextBox).Text = Nothing...
12
by: Mats Lycken | last post by:
Hi, I'm creating a CMS that I would like to be plug-in based with different plugins handling different kinds of content. What I really want is to be able to load/unload plugins on the fly without...
2
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a...
3
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the...
13
by: Michael | last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I would like to set that value from the UserControl, but I can't seem to find a way to do this. Does anyone have any ideas?...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
6
by: Igor | last post by:
Hi How can I reference a specific control in a web user form from web form's (page) code behind. In other words: I have a page (a web form) that has a web user form in it. I want to read a value...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.