Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2005, 12:00 PM
Authorized User
 
Join Date: Mar 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Overriding the ispostback method

Hi folks

I have created a web form with an asp listbox and asp:button in Dreamweaver MX. The listbox captures dynamic information from a column in an Access table I have set up called ModTitle. I have no problem displaying this information. The problem is I want the form to direct to a page called "DisplayResults.aspx", which of course it doesn't since on submit, the page posts back to itself.

I know how to post to a results page using standard html forms and listboxes (adding values), however I have created an admin section to my site, so when the user adds a module, I want the module to be displayed in the listbox. This is why I need to use asp.net controls. Is there a way to override ispostback?
Also on the DisplayResults page do I need to declare a form variable with the listboxs ID. An SQL statement like SELECT * FROM Modules WHERE ModTitle like listbox1?

Code for Likstbox Search

Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet 
id="dsSearchMod"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_connOpenDay") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_connOpenDay") %>'
CommandText='<%# "SELECT *   FROM Modules" %>'
Debug="true"
> </MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" runat="server" method="post" action="DisplayResults.aspx" >
  <p> 

    <asp:dropdownlist AutoPostBack="false" DataSource="<%#dsSearchMod.DefaultView%>" DataTextField="ModTitle" ID="SearchMod" runat="server"></asp:dropdownlist>
    <asp:button ID="button" runat="server"></asp:button>
  </p>
  <p></p>
</form>
<p>&nbsp;</p>
</body>
</html>
Code for DisplayResults

Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet 
id="dsDisplay"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_connOpenDay") %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_connOpenDay") %>'
CommandText='<%# "SELECT *  FROM Modules WHERE SearchMod = ModTitle" %>'
Debug="true"
> 
  <Parameters> 
    <Parameter  Name="SearchMod"  Value='<%# IIf((Request.Form("SearchMod") <> Nothing), Request.Form("SearchMod"), "") %>'  Type="WChar"   /> 
  </Parameters>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>DisplayMod Results</p>
<table width="75%" border="1">
  <tr> 
    <td width="27%" height="23">ModCode </td>
    <td width="73%"> <%# dsDisplay.FieldValue("ModCode", Container) %> </td>
  </tr>
  <tr>
    <td height="23">Title</td>
    <td>
      <%# dsDisplay.FieldValue("ModTitle", Container) %>
    </td>
  </tr>
  <tr>
    <td height="23">Level</td>
    <td>
      <%# dsDisplay.FieldValue("ModLevel", Container) %>
    </td>
  </tr>
  <tr>
    <td height="23">Lect</td>
    <td>
      <%# dsDisplay.FieldValue("ModLecturer", Container) %>
    </td>
  </tr>
  <tr>
    <td height="23">Aims</td>
    <td>
      <%# dsDisplay.FieldValue("ModAimsObj", Container) %>
    </td>
  </tr>
  <tr>
    <td height="23">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp; </p>
</body>
</html>
 
Old April 1st, 2005, 12:44 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

How is it that overriding IsPostback help you with this?
I think that if you want to gain granularity, the way to do it would
be to add more info to the test:
Code:
  If IsPostback [u]AND</u> <some other contition> . . .
 
Old April 1st, 2005, 08:05 PM
Authorized User
 
Join Date: Mar 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know if overriding will help. All I know is that I want the asp button to direct to the DisplayResults page and not to form's page.

 
Old April 6th, 2005, 02:50 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Change the form's action URL.
Alternately, when the page is posted back to itself, you can redirect to the other page.
You can use either Response.Redirect or System.Transfer for that.





Similar Threads
Thread Thread Starter Forum Replies Last Post
what is isPostBack amin_pucit ASP.NET 1.x and 2.0 Application Design 2 October 9th, 2013 06:30 AM
new keyword vs method overriding anand_instra C# 1 April 30th, 2008 01:46 PM
IsPostBack lamdog ASP.NET 1.0 and 1.1 Basics 1 March 30th, 2005 10:42 AM
IsPostBack() swastikagaur ASP.NET 1.0 and 1.1 Basics 3 March 18th, 2005 09:12 AM
IsPostback executed twice amantona ASP.NET 1.0 and 1.1 Professional 3 February 3rd, 2005 08:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.