Wednesday, March 21, 2012

passing variables....

i am trying to pass a variable called EventID (which is read from my SQLDataBase) from my aspx page box to a textbox in the showmodaldialog.

I have a main aspx page called Main_calendar, where when you click a hyperlink a showmodaldialog box appears giving you two options: edit or delete. on the showmodaldialog box there is also a textbox (not visible at runtime) where i would like the EventID to be written to. when you click either of the two link buttons, a new aspx page is opened, which will take the eventID written in that textbox and perform a query based on it in the new edit/delete page.

im extremely stuck as to how i can retrieve this value and input it into the texbox first and then take the value of the textbox and write it to another webform. my programming isnt so great so please bear with me!

i can see how to to do the edit/delete query if i can just get the value written in the textbox into the webform - then the rest should just be easy (touch wood). but i just dont know where to start on the first bit! ive been stuck on this for days,

id greatly appreciate anyones help on this, thanks!

code attached as below:

Main_calendar code page:

int

evID = (int)dr["EventID"];

HyperLink link =new HyperLink();
link.ForeColor = Color.FromName(evColor);
link.ID = " + evID + ";
link.NavigateUrl = "#";
link.Attributes.Add("onClick", "window.showModalDialog('UpdateDeleteDialog.aspx', null, 'dialogHeight: 130px; dialogWidth: 235px; edge: Raised; center: Yes; help: No; resizable: No; status: No; ')");

evID is the Id of the event that i wish to write to a textbox on the UpdateDeleteDialog page

updatedeletedailog page

using

System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CalendarBCP
{
///<summary>
/// Summary description for UpdateDeleteDialog.
///</summary>publicclass UpdateDeleteDialog : System.Web.UI.Page
{
protected System.Web.UI.WebControls.LinkButton LnkBtn_EditEvent;
protected System.Web.UI.WebControls.LinkButton LnkBtn_DeleteEvent;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.LinkButton Btn_Cancel;
protected System.Web.UI.WebControls.TextBoxTxt_EventID;
protected System.Web.UI.WebControls.Panel Panel1;

privatevoid Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

private

void Btn_Cancel_Click(object sender, System.EventArgs e)
{
Btn_Cancel.Attributes.Add("onclick", "window.close(); return:false;");
}privatevoid LnkBtn_EditEvent_Click(object sender, System.EventArgs e)
{
LnkBtn_EditEvent.Attributes.Add("onclick", "window.open(UpdateEvent.aspx);");
}privatevoid LnkBtn_DeleteEvent_Click(object sender, System.EventArgs e)
{
Response.Redirect("DeleteEvent.aspx");
}

Txt_EventID id the textbox in the UpdateDeleteDialog page where the eventId should be written

updatedeletdialog html:

<%@dotnet.itags.org. Page language="c#" Codebehind="UpdateDeleteDialog.aspx.cs" AutoEventWireup="false" Inherits="CalendarBCP.UpdateDeleteDialog" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>

<HEAD>

<title>UpdateDeleteDialog</title>

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">

<meta content="C#" name="CODE_LANGUAGE">

<meta content="JavaScript" name="vs_defaultClientScript">

<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

</HEAD>

<body ms_positioning="GridLayout">

<form id="Form1" method="post" runat="server">

<asp:Panel id="Panel1" style="Z-INDEX: 105; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"

Width="216px" Height="64px" BackColor="Gainsboro">

<P>

<asp:Label id="Label1" runat="server" BackColor="DarkGreen" Height="24px" Width="200px" ForeColor="White"

Font-Size="10pt" Font-Names="Tahoma">Please Select one of the following:</asp:Label>

<asp:TextBox id="Txt_EventID" runat="server" Width="72px" Visible="False"></asp:TextBox><BR>

<asp:LinkButton id="LnkBtn_EditEvent" runat="server" BackColor="Transparent" ForeColor="DarkGreen"

Font-Size="10pt" Font-Names="Tahoma">Edit Event</asp:LinkButton>

<asp:LinkButton id="LnkBtn_DeleteEvent" runat="server" ForeColor="DarkGreen" Font-Size="10pt" Font-Names="Tahoma">Delete Event</asp:LinkButton>

<asp:LinkButton id="Btn_Cancel" runat="server" ForeColor="DarkGreen" Font-Size="10pt" Font-Names="Tahoma">Cancel</asp:LinkButton></P>

</asp:Panel></form>

</body>

</HTML>

Thanks in advance!

1. Not related to your question, but move ALL of your Attributes.Add statements into the Page_Load event handler.
2. Check here for the ways to pass varibles using showModalDialog:
http://forums.asp.net/thread/1240957.aspx

NC...


Thanks! just what i need!Big Smile [:D]

0 comments:

Post a Comment