|
Suppose: You have one textbox called "TextBox1" in MasterPage. You wanna get the value of Textbox1 from child page..
So, use the following code.
object txt = this.Master.FindControl("TextBox1");<br />
Console.Write(txt.Text);
|
|
|
|
|
hi
thank u for ur reply
iam able to read the values but the issue is once i clk Master(button) iam not able to retain the values of textbox....
|
|
|
|
|
humm..
You have one textbox called Textbox1 and Button1 in your Masterpage. what you wanna do is that you wanna get the value of textbox1 in the click event of button1.
Is that what you want??
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
Console.WriteLine(TextBox1.Text);<br />
}
|
|
|
|
|
on the postback iam not able maintain the state of (master)text box in child page.....
In Master Page
<asp:button id="Button2" runat="server" style="color:White;background-color:#67AEE4;border-width:0px" postbackurl="~/Default6.aspx" text="Button">
<asp:textbox id="Header1_txtword" runat="server" enableviewstate="true">
In child page
if i enter "ravi" in textbox and clik on button iam not able to see the ravi in textbox..........
i hope its clear.....
|
|
|
|
|
Master Page.
==========
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</form>
</body>
</html>
----------------------
Child Page
==========
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
Run the application. Put "ravi" in Textbox1. Click Button1. You will still see the "ravi" that you put..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
hey
iam using postback url for (master) button to redirect to another child page
where i need to display the data....
In master page
<asp:button id="Button2" runat="server" text="search" postbackurl="~/Default6.aspx?">
<asp:textbox id="Header1_txtword" runat="server" enableviewstate="true">
In Child Page..
string str = Request.Form["ctl00$Header1_txtword"].ToString();
once i clik on button the value in text box disapperaing....
-- modified at 3:24 Tuesday 10th July, 2007
|
|
|
|
|
create a master page object and call the master page controls using this master page object!!!!
I was born dumb!!
 Programming made me laugh  !!!
--sid--
|
|
|
|
|
in master page
<asp:textbox id="TextBox1" runat="server">
<asp:button id="Button1" runat="server" postbackurl="default.aspx">
in default.aspx
if i clk on button i am not able to retain the value....
|
|
|
|
|
Hi...!
i want to play a single background sound\music through out my website. I dont want to break the sequence of this BAckground sound even the page changes.
|
|
|
|
|
>>I dont want to break the sequence of this BAckground sound even the page changes.
Very tough requirement....
Maybe. you can create the whole website with Flash.
OR maybe. you can use ajax to change the page without loading the whole page.
|
|
|
|
|
you can use iframe and hedden iframe
study hard
|
|
|
|
|
1. When the website homepage loads make a frameset like 0%,100% with 0 border.
2) Your website should in the 100% frame always.
3) Now you can have a EMBED tag with the sound\music with loop=1 in the top frame.
|
|
|
|
|
hi ..
exception handling with session store the data in database in asp.net 2.0..
some times session end so but the data is not disply &(closed).so .how to restrict this problem plz tell me as soon as possible.....
avananda reddy
|
|
|
|
|
avananda reddys 123 wrote: exception handling with session store the data in database in asp.net 2.0..
Please make your question more clear ? Are you using SQL Server session mode ?
|
|
|
|
|
Hi, I'm trying to read a blob with the following code but got the error message"You have an error in your SQL syntax".
Dim i As Integer<br />
For i = 0 To ListBox2.Items.Count - 1<br />
If ListBox2.Items(i).Selected Then<br />
Dim myCon As New OdbcConnection<br />
<br />
<br />
myCon = New OdbcConnection("Driver={MySQL ODBC 3.51 Driver};Server=myServer;Database=myDB;User=myUser;Password=myPass;Option=3;")<br />
Dim cmd As New OdbcCommand("SELECT * FROM myTable where Professions = 'ListBox2.Items(i).Text' ")<br />
<br />
myCon.Open()<br />
<br />
cmd.Connection = myCon<br />
<br />
Dim ds As New DataSet<br />
<br />
Dim ad As New OdbcDataAdapter(cmd)<br />
<br />
ad.Fill(ds)<br />
<br />
Me.ListBox2.DataSource = ds<br />
<br />
Me.ListBox2.DataTextField = "CategoryName"<br />
<br />
'Me.ListBox2.DataValueField = "CategoryID"<br />
<br />
Me.ListBox2.DataBind()<br />
End If<br />
Next<br />
I have looked up the Select statement and the where clause online to see if they are in the correct format. As far as I can see they appear to be in the correct format. Please help me determine the cause of the error, thank you in advance for your help.
-- modified at 1:44 Tuesday 10th July, 2007 
|
|
|
|
|
Did you Run your Query in the SQL Server.
What error it shows?
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
The error message that VS2003 shows is as follows.
ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.41-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.Text' at line 1
Line 92: Dim ad As New OdbcDataAdapter(cmd)
Line 93:
Line 94: ad.Fill(ds)
Line 95:
Line 96: Me.ListBox2.DataSource = ds
|
|
|
|
|
Look more closely at the select statement you're constructing...
"SELECT * FROM myTable where Professions = 'ListBox2.Items(i).Text' "
You are not appending the Text property of ListBox2.Items(i), the WHERE clause is being set to the string literal 'ListBox2.Items(i).Text'.
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
That's exactly what I wanted. The select statement is supposed to select my table where the name of the profession is equal to the text of the list item being selected. I'm trying to display the content of the field Resume Where the profession field is equal to list item being selected.
|
|
|
|
|
Look at it again. The query you're sending is;
SELECT * FROM myTable where Professions = 'ListBox2.Items(i).Text'
NOT
SELECT * FROM myTable where Professions = 'ExampleProfessionFromListBox'
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
Hi, in my database table the Resumes field stores resumes in blobs and each resume in the Resumes field has a corresponding profession which is stored in the Professions field. I am trying to enable users to search for resumes by selecting a single profession or many professions in the listbox. The select statement is supposed to select the resumes in mytable where the Professions field has the profession(s) that is/are equal to the text of the listitem(s) that the user has selected. Is this the wrong way to go about it? If it is how should I utilize the For-Next loop so that the listitem selected matches the profession in the Professions field? I tried your example but it didn't work, perhaps I did not know how to implement your example correctly. Please elaborate a little more and give another example. This is what I had done after seeing your example
("SELECT * FROM Contenttbl where Professions = 'ListBox2.Items(i).Text from ListBox2'")
Thank you again for your help.
-- modified at 14:39 Tuesday 10th July, 2007
|
|
|
|
|
You need to get the value of the Text property, (which is already a string type), and get that into your Sql string. Ideally you'd utilise stored procedures and pass in parameters, but we won't go there yet.
Your problem is here;
= 'ListBox2.Items(i).Text from ListBox2'
All this does is put the string value 'ListBox2.Items(i).Text from ListBox2' as your where clause. The statement;
ListBox2.Items(i).Text
...will get you the string value you want.
Try the below, (I usually use c# so it may not be syntactically spot on), and look at the difference between what you've got;
"SELECT * FROM Contenttbl where Professions = '" & ListBox2.Items(i).Text & "'"
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
Thank you so much for responding, I have tried your suggestion and it worked.
-- modified at 2:07 Wednesday 11th July, 2007
|
|
|
|
|
Sorry if this sounds patronising, but I'd say the important thing here is to see and understand the difference in both statements so do take the time to make sure you do, it'll be far more helpful in the long run
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
Hi,
I have a textbox which gets value from a calender control.To avoid users from manually typing I have diabled the textbox,The problem is on Postback the Textbox value i.e the date value is getting cleared.
I have also tried it using Readonly Property same problem.
Can any one please give me a solution ,
Thanks is Advance.
Archana
|
|
|
|