|
-
Jan 15th, 2010, 04:09 PM
#1
Thread Starter
Frenzied Member
include a variable in html
HI,
I need to do this simple code in html. I need to include a variable(fullname) from Comments.html inl another form like
'Fullname' thankyou for giving us your comments.
thankyou
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Jan 15th, 2010, 07:27 PM
#2
Lively Member
Re: include a variable in html
You should have a patter that is not easy to be mixed with the remaining content. For instance you can say:
%%Fullname%% thankyou for giving us your comments.
Then before you display the page get the content and replace the %%Fullname%% with an appropriate value.
Code:
TheContent = TheContent.Replace("%%Fullname%%", FullNameTextBox.Text)
-
Jan 16th, 2010, 09:23 AM
#3
Re: include a variable in html
Hey,
The code above would be used within the Server Side code of an ASP.Net Application, but you specifically mention using html.
Can you perhaps give some more information about what exactly you are trying to achieve so that we can make sure you get it working.
Gary
-
Jan 17th, 2010, 06:02 AM
#4
Thread Starter
Frenzied Member
Re: include a variable in html
I am trying to import the user name (fullname) which is inputted in a textbox from another page within the same webpage and get it to show up. Like
Angelica, thankyou for you comments
where Angelica would have been inputted in the texbox for the username.
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Jan 17th, 2010, 07:46 AM
#5
Re: include a variable in html
this is not an HTML but to get the textbox value of the previous page from the code behind you should do something like:
Code:
string FullName = ((TextBox)Page.PreviousPage.FindControl("txbFullName")).Text;
you can also get the textbox value with the form collection
Code:
string fullName = Request.Form["txbFullName"];
if you using master page and using the "Request.Form" method you should take into consideration that the textbox control ID will change and then you should use the ClientID property.
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 17th, 2010, 03:15 PM
#6
Re: include a variable in html
Hey,
Are these user's people who have logged into your website, or can these be any people? If they are logged into your website already, then you can get this information from the built in methods within the Framework.
Or, in addition to the methods that motil has mentioned, you could put the username into a Session variable, or append it to the QueryString.
There are a number of different ways to do this, it just depends on exactly what you are doing, and why you are doing it.
Gary
-
Jan 18th, 2010, 03:42 PM
#7
Re: include a variable in html
Page2:
Label1.Text = String.Format("{0}, thank you for your comments", firstName);
On Page1, you can accept the user's comments in the button click event, save or email it (or whatever you want to do), then either
Response.Redirect("~/page2.aspx?name=" + TextBox1.Text);
or
Session["firstName"] = TextBox1.Text;
Response.Redirect("~/page2.aspx");
-
Jan 20th, 2010, 05:52 AM
#8
Thread Starter
Frenzied Member
Re: include a variable in html
Hi ALL,
thanks for your replies. Is there a way to do the same thing using only HTML? I am teaching this class of student where I can only use html and they have no ASP.Net knowledge.
thanks
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Jan 20th, 2010, 05:55 AM
#9
Re: include a variable in html
as far as i know, nope.... maybe with javascript/.
* Rate It  If you Like it
__________________________________________________________________________________________
" Programming is like sex: one mistake and you’re providing support for a lifetime."
Get last SQL insert ID 
-
Jan 20th, 2010, 05:55 AM
#10
Re: include a variable in html
Hey,
If your question was specifically related to using only HTML, why did you post in the ASP.Net forum?
One way you could do this would be to use JavaScript to get the value in the querystring, and change the label value.
Here is one implementation:
http://www.bloggingdeveloper.com/pos...avaScript.aspx
Gary
-
Jan 20th, 2010, 01:32 PM
#11
Re: include a variable in html
On the first page, you can set the form's method to get
<form action="page2.html" method="get">
<input type="text" id="fname" name="fname" />
<input type="submit" value="go" />
</form>
When you click submit, it'll go to
page2.html?fname=blah&something=something
So you could then use that javascript to read the querystring and write it to the page. If page2 has a textbox for example, you could use
document.getElementById('page2textbox').value = valueFromQueryString;
-
Jan 20th, 2010, 01:32 PM
#12
Re: include a variable in html
Would you like this moved to the HTML forum?
-
Jan 21st, 2010, 04:14 AM
#13
Thread Starter
Frenzied Member
Re: include a variable in html
Thanks
Yes I think it more belongs to the HTML . Thankyou.
------------------------------------------------------------------------
If an answer to your question has been helpful, then please, Rate it! 
-
Jan 22nd, 2010, 03:13 AM
#14
Re: include a variable in html
Moved.
Did you try what we've suggested so far?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|