no postback on specific page - asp.net

I am using asp.net Routes in the Global.asax:
routes.MapPageRoute("Home", "home", "~/index.aspx");
routes.MapPageRoute("Profiles", "profile/{nick}/{profid}", "~/Profile.aspx");
I have in my master page a top menu, in which there is a LinkButton with OnClick event.
Problem is, the postback works only on routed pages like "HOME" but not in the Profile (which is constructed out of /asdf/12345 instead of just /1235.
When clicking the top menu LinkButton in the profile page I get 404 page.
it doesnt even post to the page!
what can be wrong?
thanks

Problem solved.
I had to put in my Masterpage:
this.form1.Action = Request.RawUrl;
this fixed the form's action!

Related

How to get data from master page to child page in asp.net

Currently, in a dot net project, i have a master page & a child page. I have given various options, like textbox, combo box etc, on a master page with a submit button. Now i have a child page where i want to process the request sent by master page.
I have heard that retaincontrolstate is used like
private void retainControlState()
{
}
But currently i am not recieving the values from the masterpage onto the child page, not even the click event of the master page.
How can i make the click of master page button to send the request to the child page ?
You should:
Make sure you can access the controls on your master page from the page, e.g. make them public fields
In the Page_Init of your page, cast your the Master property to its proper type (or just use the MasterType directive - https://msdn.microsoft.com/en-us/library/ms228274(v=vs.100).aspx)
Then you can hook up the event handler in your page to the controls on your master page
ControlState has nothing to do with this.
Does it make sense to handle stuff on your master page in your content page's code-behind though? Why not simply do this in the Master page's code-behind?

URL rewriting, postback doesn't work for controls in master page

Bog standard postback stuff going on a la this link: http://ruslany.net/2008/10/aspnet-postbacks-and-url-rewriting/
Adding form1.Action = Request.RawUrl; fixes it as you'd expect, but there is one bug...
I have an ashx which serves a page depending on the parameters. This page, and in fact, all pages, have a Page.master masterpage. On this page is a button, and it is hooked into an onclick event in the codebehind. Clicking this button however does nothing, because the form action code above is breaking it. If I comment it out the button click works fine, but none of my navigation does.
mysite.com/cats/123 is picked up by my ashx using rewrite just like the example up top.
When the button is clicked, the form1.Action = Request.RawUrl; which is in the master page load event fires, and sets the action to mysite.com/cats/123 as you'd expect.
At this point the page is served, but the onclick method (which is in the master page) does not fire. Any idea why?
Edit: Maybe my ashx has to do something to preserve the postback data?

asp.net ajax popupcontrol items show briefly on page

I have a usercontrol on my page. The user control contains an ajax updatepanel with a listbox in it. There is also a PopupControlExtender that is tied to that panel so when the user clicks on something the popup shows. That is all working fine except when my page initially loads I briefly see all the listbox items and then they go away.
Got it:
style="display:none" on the updatepanel

After click button the page content are gone (invisible)

I've a page and I've postpack control in my cs file.
For example in post.aspx page users can comment.
They give name, email, url and comment and then click send button.
After click send button page content are gone.
Why is this happened?
Again I have a postback control in page_load like
if(!page.ispostback)
Probably you're creating dynamic controls (programmatically appended to the page) and you don't recreate them on postback.
More details about what you're doing would help though.
As Claudio Redi mentions, you're properly setting the content of the label and the div, inside
if (!Page.IsPostBack)
This means, that the code will not be run, if a button is clicked. This will only run, the first time you're visiting the website.

ASP.NET and jQuery - submitting forms from a modal box?

I have an ASP.NET web site with master/content pages. On the master page, there is a link to log-in and that brings up a modal jQuery form. How can I make sure that the info that is submitted on this form (which is just a DIV in my master page) is handled by a particular postback event?
Keep in mind that the modal can be submitted from any number of pages and I want to make sure that when the modal is submitted, the postback event of the content page is ignored while the postback of the master page handles the form.
if you leave the postback address blank (in html) it will post to the same page. if you can't do this, try passing in a variable with the page's address.
You can't prevent your Content page from detecting that a postback has happened. The way MasterPages/Content Pages work is that the MasterPage is applied to the Content page after OnPreInit at that point the MasterPage is accessibly from the Content page. However, if you define the button handler in your MasterPage
<asp:Button ... OnClick='myHandler'>
you can do any processing from within the MasterPage's code-behind.
protected void myHandler(object sender, EventArgs e)
{...handle button click...}
But, that handler will be triggered after the Content page and Master Page has fired all events before the OnLoadComplete() page method

Resources