473,403 Members | 2,183 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,403 software developers and data experts.

Accessing form data

I have 3 ASP.NET forms written in C#, I also have 3 frames (left, top and bottom) one for each form. My question is if I have data on one form in the bottom frame how do I access this data when I click on the button which is on the top frame?

I want to save the data from the bottom frame to the database when a user clicks on the Update button.

Does anyone have an example on how to do this?

-----------------------------------------------------
| | Top |
| | |Update| |
| |---------------------------------------|
| | Bottom |
| Left | |
| | _Data_ _Data_ _Data_ _Data_ |
| | |
| | _Data_ _Data_ _Data_ |
| | |
-----------------------------------------------------

--
Thanks
-------------------
cz****@wsinc.com
Nov 18 '05 #1
5 1970
Use javascript to submit the Bottom form.

window.frames['frameName'].document.body.all['Form1'].submit();

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
Hi Peter,
Welcome to Microsoft Newsgroup Service. Based on your problem description,
you've a frameset which has three frames(left,right top and right bottom).
There is a button in the right top frame's page and some entry fields in
the right bottom page, you want to let the datas to be saved( submit to the
serverside?) when the button in the right bottom frame is clicked?

If so , I think suggestion provided by Natty is good. You can write a
period of client javascript and when the button in the right top frame is
clicked, run the script and find the right bottom frame , then call the
form(in the right bottom frame's page) 's submit() method to post the data
to the serverside, For example:

suppose we 've a frameset page as:

<frameset id="fsleft" cols="20%,80%">
<frame name="left" src="SideMenu.aspx" scrolling="no" noresize
style="BACKGROUND-COLOR: #ffffcc">
<frameset id="fsright" rows="16%,84%">
<frame name="rtop" src="TopMenu.aspx">
<frame name="rbottom" src="MainScreen.aspx">
</frameset>
</frameset>
and in the TopMenu.aspx, there exists a button and we define a javascript
function to call the rbottom frame's page's submit() method:
.........
<script language="javascript">
function SubmitBottomPage()
{
window.parent.frames['rbottom'].document.Form1.submit();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><INPUT type="button" value="SubmitButtomPage"
onclick="SubmitBottomPage()"></td>
</tr>
</table>
</form>
</body>

Thus, when the button "SubmitButtomPage" is clicked, it'll call the
"SubmitBottomPage()" function and in that function,
we use window.parent.frames['rbottom'] to get the right bottom frame's page
and call it's document.Form1 element's submit method.

The MainScreen.aspx(the page in the "rbottom" frame) is like bellow:
...................
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><FONT face="ËÎÌå">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></FONT></td>
<td><FONT face="ËÎÌå">
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox></FONT></td>
<td><FONT face="ËÎÌå">
<asp:TextBox id="TextBox3" runat="server"></asp:TextBox></FONT></td>
</tr>
</table>
</form>
</body>

When the page is submited, all the data is posted to the serverside, you
can retrieve them in the page's Page_Load event.

Please try the preceding suggestion and let me know whether they help,
Thanks.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Thanks for your help!

This works!

One more question!
The Page_Load event fires when the page gets loaded initialy and once again
when you submit the form, is there a special flag that I can test to see if
data has been entered / changed on the form by the user or do I have to set
my own flag?

"MSFT" <v-******@online.microsoft.com> wrote in message
news:od**************@cpmsftngxa07.phx.gbl...
Hi Peter,
Welcome to Microsoft Newsgroup Service. Based on your problem description,
you've a frameset which has three frames(left,right top and right bottom).
There is a button in the right top frame's page and some entry fields in
the right bottom page, you want to let the datas to be saved( submit to the serverside?) when the button in the right bottom frame is clicked?

If so , I think suggestion provided by Natty is good. You can write a
period of client javascript and when the button in the right top frame is
clicked, run the script and find the right bottom frame , then call the
form(in the right bottom frame's page) 's submit() method to post the data
to the serverside, For example:

suppose we 've a frameset page as:

<frameset id="fsleft" cols="20%,80%">
<frame name="left" src="SideMenu.aspx" scrolling="no" noresize
style="BACKGROUND-COLOR: #ffffcc">
<frameset id="fsright" rows="16%,84%">
<frame name="rtop" src="TopMenu.aspx">
<frame name="rbottom" src="MainScreen.aspx">
</frameset>
</frameset>
and in the TopMenu.aspx, there exists a button and we define a javascript
function to call the rbottom frame's page's submit() method:
........
<script language="javascript">
function SubmitBottomPage()
{
window.parent.frames['rbottom'].document.Form1.submit();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><INPUT type="button" value="SubmitButtomPage"
onclick="SubmitBottomPage()"></td>
</tr>
</table>
</form>
</body>

Thus, when the button "SubmitButtomPage" is clicked, it'll call the
"SubmitBottomPage()" function and in that function,
we use window.parent.frames['rbottom'] to get the right bottom frame's page and call it's document.Form1 element's submit method.

The MainScreen.aspx(the page in the "rbottom" frame) is like bellow:
..................
<body>
<form id="Form1" method="post" runat="server">
<table width="500" align="center">
<tr>
<td><FONT face="ËÎÌå">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></FONT></td>
<td><FONT face="ËÎÌå">
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox></FONT></td>
<td><FONT face="ËÎÌå">
<asp:TextBox id="TextBox3" runat="server"></asp:TextBox></FONT></td>
</tr>
</table>
</form>
</body>

When the page is submited, all the data is posted to the serverside, you
can retrieve them in the page's Page_Load event.

Please try the preceding suggestion and let me know whether they help,
Thanks.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
Hi Peter,
Thanks for your response. As for your question in the reply, I think you
need to add a custom flag yourself in the page which is to be submited.
Because you submit the whole page, the serverside won't know whether one of
the entry field has been modified or not. To manually add a flag, I think
you can add a hidden input area in the page(set as runat server) to perform
the flag, just like:

//default value is "no" indicate that no entry fields has been modified
<input type="hidden" name="ModifyFlag" id="ModifyFlag" runat="server"
value="no" />

and in the page , add a javascript function to modified the hidden input
area:
<script language=javascript>
function SetModifyFlag()
{
document.Form1.ModifyFlag.value = "yes"
}
</script>
Then, in other entryfield's client attributes, add a "onchange" event set
as the "SetModifyFlag" function, for example:

<input type="text" id="txtName" name="txtName" runat="server"
onchange="SetModifyFlag()">
Since this is a client script, when the textbox's value is changed ,the
"ModifyFlag" hidden area's value'll be set as "yes"
#note that you'd better use <input type="text" runat="server"/> rather than
the <asp:textbox> because the html serveside control is easier to set its
client attributes than the ASP.NET webcontrol.

Thus in the serveside code, you can check the value to know whether any
entryfield has been modified:

private void Page_Load(object sender, System.EventArgs e)
{
if(ModifyFlag.Value.Equals("yes")
{
//do operations..........
}

}
Please try the preceding suggestion and let me know whether they help,
Thanks.

Merry Christmas!!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #5
Thank you for your help!

I think this is what I need!

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:7b**************@cpmsftngxa07.phx.gbl...
Hi Peter,
Thanks for your response. As for your question in the reply, I think you
need to add a custom flag yourself in the page which is to be submited.
Because you submit the whole page, the serverside won't know whether one of the entry field has been modified or not. To manually add a flag, I think
you can add a hidden input area in the page(set as runat server) to perform the flag, just like:

//default value is "no" indicate that no entry fields has been modified
<input type="hidden" name="ModifyFlag" id="ModifyFlag" runat="server"
value="no" />

and in the page , add a javascript function to modified the hidden input
area:
<script language=javascript>
function SetModifyFlag()
{
document.Form1.ModifyFlag.value = "yes"
}
</script>
Then, in other entryfield's client attributes, add a "onchange" event set
as the "SetModifyFlag" function, for example:

<input type="text" id="txtName" name="txtName" runat="server"
onchange="SetModifyFlag()">
Since this is a client script, when the textbox's value is changed ,the
"ModifyFlag" hidden area's value'll be set as "yes"
#note that you'd better use <input type="text" runat="server"/> rather than the <asp:textbox> because the html serveside control is easier to set its
client attributes than the ASP.NET webcontrol.

Thus in the serveside code, you can check the value to know whether any
entryfield has been modified:

private void Page_Load(object sender, System.EventArgs e)
{
if(ModifyFlag.Value.Equals("yes")
{
//do operations..........
}

}
Please try the preceding suggestion and let me know whether they help,
Thanks.

Merry Christmas!!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6

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

Similar topics

1
by: JC | last post by:
How do I extract data from a form into the main form for processing? For instance, I have several image files in a form called images(images.frm), indexed from 0 to 99, and I want to import these...
5
by: Craig Anderson | last post by:
Can anyone tell me the best way to access a hidden object in a form? I could use a hard-coded index to the elements of the form, but it's too easy to add something before the hidden object and mess...
1
by: Esben Rune Hansen | last post by:
Hi I am working on a PHP-script and need javascript to set the value of a hidden field in a form. This field happens to be an entry in an array data according to my example. How can I do this? ...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
2
by: Barry Schwarz | last post by:
Given a union of the form union { T1 m1; T2 m2;}obj; where T1 and T2 are different scalar (non-aggregate) types. The C99 standard states that obj.m1 = value; if (obj.m2 ... invokes...
1
by: spalding | last post by:
Hi I have a situation in which I need to find out how much data has bee posted during a form's POST method. The amount of data I am posting is large (the form includes a fil input) and I wish...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
4
by: Noy B | last post by:
Hi, I have developed a small application that is using a MSAccess DB. the problem is that it was developed on a machine where the application and the DB are both located. now it needs to be...
4
by: nottarealaddress | last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work after officially stopping new development in VB6 about a month ago). I'm working with a simple sql 2005 table of 50 entries, one...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.