473,394 Members | 1,759 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,394 software developers and data experts.

Why does postbackurl and master pages work like this?

I have a search box on my master page. The results are on a child
page. To do this I changed the postbackurl to the childpage and on the
childpage I have an asp:controlparameter matching the name of the
control on the master page.

The first time I press the button on the master page it goes to the
child page, but no results are displayed in my gridview. The second
time I press my button (which is still the master page button no other
buttons) the query works and the grid is populated.

Why does it act like this? Why do I have to hit it twice?

Thanks for any help.

Apr 9 '06 #1
6 5143
Any code samples? In general you shouldn't have to change the postbackurl
since the content page is the actual page being rendered, the master page is
added to it. The only thing you should have to do, is make the value on the
master page visible to the content page.

"ne***********@gmail.com" wrote:
I have a search box on my master page. The results are on a child
page. To do this I changed the postbackurl to the childpage and on the
childpage I have an asp:controlparameter matching the name of the
control on the master page.

The first time I press the button on the master page it goes to the
child page, but no results are displayed in my gridview. The second
time I press my button (which is still the master page button no other
buttons) the query works and the grid is populated.

Why does it act like this? Why do I have to hit it twice?

Thanks for any help.

Apr 9 '06 #2
How do I make the "make the value on the master page visible to the
content page."?

Larry Charlton wrote:
Any code samples? In general you shouldn't have to change the postbackurl
since the content page is the actual page being rendered, the master page is
added to it. The only thing you should have to do, is make the value on the
master page visible to the content page.

"ne***********@gmail.com" wrote:
I have a search box on my master page. The results are on a child
page. To do this I changed the postbackurl to the childpage and on the
childpage I have an asp:controlparameter matching the name of the
control on the master page.

The first time I press the button on the master page it goes to the
child page, but no results are displayed in my gridview. The second
time I press my button (which is still the master page button no other
buttons) the query works and the grid is populated.

Why does it act like this? Why do I have to hit it twice?

Thanks for any help.


Apr 9 '06 #3
Perhaps you could do a page redirect in your search button's click
handler that passes the keyword to your search page, e.g.

protected void btnSearch_Click(object sender, EventArgs e)
{
Response.Redirect("Search.aspx?keywords=" +
HttpUtility.HtmlEncode(txtKeyword.Text);
}

You could then get the keywords from Request.QueryString and build you
results in the GridView?

HTH,

Chris

Apr 9 '06 #4
No way to do with all drag and drop?

My button and textbox are on the master page. My results gridview is
on the child page.

so on the child page I have:

<SelectParameters>
<asp:ControlParameter ControlID="txtFreeSearch"
Name="keywordlist" Type="String"

PropertyName="Text" />

</SelectParameters>
</asp:SqlDataSource>

and on the masterpage I have

<asp:Button ID="Button1" runat="server" Text="GO!"
PostBackUrl="~/FreeSearch.aspx" /></td>

I press the button and the FreeSearch.aspx page is called. It just
doesn't populate the gridview, but the page loads. The second time
(with the FreeSearch.aspx already loaded) I hit the button, it works.
This tells me the first time I hit the button on the master page (where
default.aspx is the content page at that time), and it posts to the
child, the data is not being passed or the SelectParameters cannot see
it for some reason.

Chris Fulstow wrote:
Perhaps you could do a page redirect in your search button's click
handler that passes the keyword to your search page, e.g.

protected void btnSearch_Click(object sender, EventArgs e)
{
Response.Redirect("Search.aspx?keywords=" +
HttpUtility.HtmlEncode(txtKeyword.Text);
}

You could then get the keywords from Request.QueryString and build you
results in the GridView?

HTH,

Chris


Apr 9 '06 #5
On 8 Apr 2006 20:44:10 -0700, ne***********@gmail.com wrote:
Why does it act like this? Why do I have to hit it twice?


My guess is that you're doing something differently in postback than you
are when not in postback. The first time you click, you're not in postback
when you click it. The second time you click, you're page has been built
with a postback event.

As someone else mentioned, you don't need to set the postbackurl because
it's already the same page. Do you have any special postback processing?
Apr 9 '06 #6
On the content page try:
<%@ MasterType VirtualPath="Site.master" %>

Any public items on the master page you can see from the content page.

Apr 10 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: osh | last post by:
All, I am having trouble using the PostBackUrl feature in .NET 2.0. I have several User Controls that are on a MasterPage. The User Controls contain the form fields for a basic search on...
0
by: wendylau81 | last post by:
We are currently using ASP.NET 2.0 to revamp one of our web applications. Let me try to briefly explain how each page is laid out... Usually within the page, there are 3 components... The...
1
by: Wendy | last post by:
I had previously posted this in inetserver.asp.components, I don't think that was the right place... anyways, here is a repost: We are currently using ASP.NET 2.0 to revamp one of our web...
0
by: Wendy | last post by:
We are currently using ASP.NET 2.0 to revamp one of our web applications. Let me try to briefly explain how each page is laid out... Usually within the page, there are 3 components... The header,...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
0
by: Fresh_Air_Rider | last post by:
Hi I have two pages which both use the same master page. Page one contains an asp:textbox control and an asp:button control with it's PostBackUrl property set to the second page. The "code...
0
by: Fresh_Air_Rider | last post by:
Hi I have two pages which both use the same master page. Page one contains an asp:textbox control and an asp:button control with it's PostBackUrl property set to the second page. The "code...
7
by: Dwight Johnson | last post by:
I am attempting to use Master Pages in a new website, and finding it troublesome. I also do not see a lot of entries in this group regarding them or their components, such as ContentPlaceHolders. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.