Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 23rd, 2004, 02:05 PM
Authorized User
 
Join Date: Nov 2003
Location: Norco, CA, USA.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default Flow Control

I'm haveing a flow control problem in a code page, SearchResults.aspx.cs, which contains:

private void Page_Load(object sender, System.EventArgs e) {

        string tryit = Request.Params["term"];
    if(tryit == null)
        Response.Redirect("SearchFailed.aspx");

    // Search database using the supplied "txtSearch" parameter
    NoLimitEngin.ProductsDB productCatalogue = new NoLimitEngin.ProductsDB();

    DataListSearch.DataSource = productCatalogue.SearchProductDescriptions(Request .Params["term"]);
    DataListSearch.DataBind();

    // Reroute if no results are found
    if (DataListSearch.Items.Count == 0) {
        Response.Redirect("SearchFailed.aspx");
    }
}

This works, and the same function in the ProductsLists.aspx.cs (without the 2 tests) also works, and has been working for some time now. But today, in both cases, the flow control now continues on to the next function below this and continues to execute. Of course it fails. But why is it happening. Does anyone have any thoughts?

The next function should only happen when a button is clicked:
public void SearchList_Select(object sender, System.EventArgs e) {
. . . .
}

and then it displays a DataGrid.




Sandy
__________________
Sandy
Reply With Quote
  #2 (permalink)  
Old February 23rd, 2004, 02:59 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Sandy,

I was kind of following the other thread about this that Imar was helping you with but I'm not quite clear on how you are getting to this page? Are you redirecting to this page after you entered a search term and hit the search button? If this page is running off of a first request from a redirect, you should certainly not be getting a button click event. That would be very odd. I suppose it's possible it could happen if you were using a Server.Transfer, but even then, I wouldn't think it would happen. You might want to paste some more code and explain in more detail the process leading up to this problem.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old February 23rd, 2004, 03:28 PM
Authorized User
 
Join Date: Nov 2003
Location: Norco, CA, USA.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peter,

Thanks for your reply. I'm using aspx controls in the UC, with the form in the file that uses the UC. However, that can't be connected with this problem, because the other file, ProductsList.aspx & .cs, that has been working, doesn't use the UC at all, in any way. And now it's not working.

So I'm re-writing it now. I've no idea what stopped it. My only idea is that I changed something in the .aspx file that caused it. I did 'clean up' a few lines, and when I edit ItemTemplate all the controls but 1 show an error. However, yesterday with those same error conditions, it ran fine.

Pasting this whole .aspx file would be a lot of stuff. I wondered if you'd seen this problem before and what caused it. Here is the line for the Button that acts, on page_load, as if it'd already been clicked:
<asp:Button id="ExpandButton" runat="server" CssClass="ProductListButton" Width="65px" Text="Details" ToolTip="Show/Hide Details" CommandName="Select"></asp:Button>

Having just pasted this, and read it, isn't the problem that the CommandName "Select" should be "SearchList_Select"?


Sandy
Reply With Quote
  #4 (permalink)  
Old February 23rd, 2004, 04:08 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The "CommandName" of a button is the command name used when that button click results in a call to an ItemCommand method for a templated control in which that button is a control of the item template, like a datalist or datagrid. The method that the button calls by itself would be specified by the appropriate handler attribute ("OnClick"). Whether or not you can have a button as a control within an item template and also have that button call a handler specified in "OnClick" I can not say. I don't see any reason why this shouldn't be allowed, but I have never tried it.

However, none of this explains why you are getting an event firing when it shouldn't be. Are you adding an event to SearchList_Select in page_init that you shouldn't be? That's the only thing I can imagine.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old February 23rd, 2004, 04:42 PM
Authorized User
 
Join Date: Nov 2003
Location: Norco, CA, USA.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter,

"Are you adding an event to SearchList_Select in page_init that you shouldn't be? That's the only thing I can imagine."

EVERYTIME I add or replace a control in the template, the .cs page removes both events Page_Load and SearchList_Select. And I put them back in.




Sandy
Reply With Quote
  #6 (permalink)  
Old February 24th, 2004, 07:12 PM
Authorized User
 
Join Date: Nov 2003
Location: Norco, CA, USA.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter,

Hope you weren't offended by EVERYTIME, I was exceedingly frustrated.

I had about 8 different errors on that page, resulting from inserting the UC while copying and pasteing from other files.

I'm using a DataList with a DtaGrid and a Button with CommandName="Select" (error fixed). The "CommandName" of a button is the command name used when that button click results in a call to an ItemCommand method for a templated control in which that button is a control of the item template, like a datalist. The DataList contains a DataKeyField.

It all works now, and I'm alsmot back to where I started makeing all these error.

Thanks very much for your help.

Sandy

Sandy
Reply With Quote
  #7 (permalink)  
Old February 25th, 2004, 01:05 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Sandy,

No, I wasn't offended, I was just baffled by the problem. I have actually recently responded to another thread that sounds like it's got similar symptoms. Something about add handler calls dissappearing when editing. It's funny (and confusing) how the same problems often pop up on the forums at the same time in different threads.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to slow down this flow jjk2 Beginning VB 6 8 January 28th, 2008 07:12 PM
If Then Else VBA Flow Help darrenb Access VBA 2 May 10th, 2007 06:35 PM
control flow aranjan ASP.NET 1.0 and 1.1 Professional 0 March 29th, 2007 12:44 PM
flow of an object catchrohith .NET Framework 2.0 0 November 18th, 2006 01:04 AM
Flow of the Program ? pandian Java Basics 2 March 20th, 2006 11:07 PM



All times are GMT -4. The time now is 07:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.