|
mattdavies wrote: However, I couldn't work out or find and examples of how you can use this object to populate a web control with data and submit the page.
Hi Matt,
In fact, you don't use the HttpWebRequest to populate a web control, instead you use it to send data to a specified URL with the Post/Get method. Let me briefly describe it in a couple of steps in order to make it clear:
- Use the HttpWebRequest object to make a request to a specified URL.
- Read the output html markup from the HttpWebResponse object.
- You can choose a value for an input element from the retrieved html markup by using the regular expression, I mean you can use the Regex class to process the markup to select a value for an element like the dropdownlist, for the TextBox, you no need to process the markup.
Another way to visually choose a value for the input element is that you load the result html markup to a web browser control, then use the document object of the browser control to populate the input element.
- Arrange the data that you're gonna submit in the expected format, then use the HttpWebRequest object to submit data to the destination URL.
Like I said in the previous post, in addition to the HttpWebRequest object, you can also use the web browser control to navigate to a specified URL, and access the document object of the control, then you are able to get reference to the input control to populate it, it simulates the way you select a value for the input control in the browser.
mattdavies wrote: Would you need to use the HttpWebResponse object in conjuction with the HttpWebRequest object?
You normally use the HttpWebRequest to make a request to a specified URL to get info, and then in order to read the result html markup sent back from the server you will use the HttpWebResponse object (which is accessed from the GetResponse method of the HttpWebRequest object that you use to make a request earlier).
|
|
|
|
|
Hi minhpc_bk,
Thanks for your help - that makes a lot more sense. Apologies for not replying sooner but I have been away for a few weeks.
Thanks again.
Matt.
|
|
|
|
|
I am working on an ASP.NET application.. I have a form with a dropdownlist that is attached to the column of a database.
I will like the rest of the textboxes to be field up automatically depending on the selection from the dropdownlist. Values are all in the same table... can anyone help with this?
Commickey
|
|
|
|
|
Hi Commickey,
If you add a SelectedIndexChanged event handler to your code, you can determine what the user has selected in the drop down list by interogating the SelectedValue of the control.
Once you have this information you can then go back to your database table and retrieve associated information and populate the relevant text boxes.
Hope this helps.
|
|
|
|
|
Matt,
Thanks for the reply...
can you please help me with some sample code?
Thanks alot...
Commickey
|
|
|
|
|
Hi Commickey,
Set autopostback property to that dropdownlist is true in the property window.
When ever you select a item in the drop down listbox, dropdown box index changed event will be fired. You write code to dispaly that row details in the tables.
double click on the dropdown box in design time you will get event function, write the code in that funcnction,
I guess it will work for you
From
Nasums
Thanks & Regards,
Nasums
|
|
|
|
|
A more elegant method would be to use AJAX - no need for postbacks (bleuuuugh!)
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I have 2 pages that validate (using validation groups) the users inputs and store them in a cookie. The first page validates and puts the in a cookie, then redirects the user to a second page where the values from the cookie are read, modified then written (overwrites the former value) in the cookie.
The code for the two pages resembles, here is a sample:
String t, s,t1;
int i = 0;
s = "";
t = "";
if (Page.IsValid)
{
t = GetCookie("test");//reads the value from the cookie possible place where the error lies.
lbl1.Text = t;
try //transforms the string in
{
lbl1.Text = t;
t1 = t.Remove(0, 9); to get the value
i = Int32.Parse(t1);
calcul(i); //calculates the new values
}
catch (Exception w) { lbl3.Text = "Conversion did work."; }
s = Convert.ToString(i);
SetCookie("test", s, 1);//writes the new value in the cookie
Response.Redirect("Test_3.aspx"); //redirects to a new page
}
The functions I tested them and work well on their and with each other
|
|
|
|
|
Hi,
I've got a problem ... Being new to ASP.NET 2.0 programming (I wrote a lot of classic ASP, and skipped the ASP.NET 1.x step ...), I'm discovering the fantastic world of WebControls.
I wrote one whose goal is to display a square box including a title, a little description and a list of links, and called it LinkBox. I would like to include child tags in the source code of my aspx pages using it, to set some items for the list, in fact, it seems to be like the ListBox behaviour. The only thing is that I don't want to use asp:ListItem objects, but my own created LinkBoxItem which contain 4 string properties.
The using code would be :
<SMWeb:LinkBox ID="LinkBox1" runat="server" Text="This is a description" Title="Title of the box"><br />
<SMWeb:LinkBoxItem Target="_blank" Desc="" Title="Site 1" url="http://www.site1.com/"></SMWeb:LinkBoxItem><br />
<SMWeb:LinkBoxItem Target="_blank" Desc="" Title="Site 2" Url="http://www.site2.com/"></SMWeb:LinkBoxItem><br />
<SMWeb:LinkBoxItem Target="_blank" Desc="le meilleur !" Title="Site 3" Url="http://www.site3.com/"></SMWeb:LinkBoxItem><br />
</SMWeb:LinkBox>
When I view the result at runtime, everything works well, but in the designer, in design view, I get a grey box containing the text :
"Error when creating control - LinkBox1
Unable to define 'SMWeb:LinkBox' for property 'Items'."
(I translated from my French Visual Studio 2005 version ...)
In order to keep this message short, I don't paste the whole piece of code of my WebControl, LinkBoxItem object and ListBoxCustomBuilder, but you can have a look at it there if you think you could help me (which I would appreciate SO much !) :
[http://forums.asp.net/thread/1275794.aspx]
Thanks for all by advance !
Stéphane
|
|
|
|
|
Hi,
How do I draw a rectangle onto an Imagebox control on an asp.net webpage when the user drags the mouse within the imagebox control?
Inserting another imagebox onto the original imagebox when the user drags the mouse is ok too
|
|
|
|
|
am developing a local site
how can i get the ip address or computer name of the server once a page is called?
there is no specified server any client is a candidate for being a server
|
|
|
|
|
Hi,
Below Code gives you the computer name,
System.Environment.MachineName
Hope helps u...
|
|
|
|
|
thx a lot
|
|
|
|
|
Hi,
I have 2 dropdownlists boxes.One for country and another for state.I have 2 tables countries and states where countrycode is a foreign key in states table.Now I WANT TO write javascript to populate the second dropdownlist based on the country selected in the first dropdown list.Now I want the code to accomplist this task.
With Regards,
Uma
|
|
|
|
|
May be it will help you
// Create arrays containing state cities
// Note: These arrays could be created dynamically
var arrStates, arrFlorida, arrNewYork, arrTennessee
arrFlorida = ["Daytona Beach", "Miami", "Orlando", "Tampa"]
arrNewYork = ["Albany","New York", "Oakland", "Rochester"]
arrTennessee = ["Gatlinburg", "Knoxville", "Memphis", "Nashville"]
arrStates =[arrFlorida, arrNewYork, arrTennessee]
// Function to handle dynamically altering the contents of the City List box
function handleChange(newDisplay)
{ var StateSelect, CitySelect, NumEntries, i
StateSelect = document.frm.States
CitySelect = document.frm.Cities
// Delete all entries in the cities list box
for (i = CitySelect.length; i > 0; i--)
{
CitySelect.options[i-1] = null
}
// Add comment option to City List box
CitySelect.options[0] = new Option("-- Select City --",0)
// If state is selected add its cities to the City List box
if (newDisplay >= 0)
{
NumEntries = arrStates[newDisplay].length
for (i = 1; i <= NumEntries; i++)
{
CitySelect.options[i] = new Option((arrStates[newDisplay])[i-1],(i))
}
}
CitySelect.selectedIndex = 0
}
-- Select State --
Florida
New York
Tennessee
-- Select City --
handleChange(-1)
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
|
|
|
|
|
Hello ,
I am getting the following error
"document.frm.States is null or not an object" what could be the reason?
Regards,
Uma
|
|
|
|
|
hi all,,,
how i can to add site(url) to favorites in asp.net????
thanks .
|
|
|
|
|
Like this
<input id="btnBookmark" type="button" value="Add To Favorites" onclick="window.external.AddFavorite(location.href, document.title);">
|
|
|
|
|
|
Hi,
What are the testing tools that are used to test a ASP.NET (c#) project? Can someone give me a good idea abt those.
Uma
|
|
|
|
|
I am trying to send Mail through System.Web.MailMessage. When I send the mail to
an address that is local to Smtp Mail Server, it reaches at the destination address. Suppose my Smtp Server is mail.123.com and my mail address is sandy@123.com. When I send mail to this address through Web.MailMessage class,it reaches the destination address with ease. However when i want to send the mail to an address that is external to SMTP Server(suppose sandy@gmail.com),it shows me an exception
Exception Details: System.Runtime.InteropServices.COMException: The server rejected one or more recipient addresses. The server response was: 550 Authentication is required for relay
Source Error:
Line 47: mail1.Subject="Just to say Hi";
Line 48: System.Web.Mail.SmtpMail.Send(mail1);
When I send the mail through Outlook Express through sandy@123.com, it easily reached at sandy@gmail.com but the above said programming method is not working. Please suggest me the solution for the above problem and any settings
that I need to perform
Thanks,
Sandy
|
|
|
|
|
How to get uppercase letters on the monthtitle in the asp:calendar control?
|
|
|
|
|
Even after setting EnableViewState=false values are still retained in my textbox.How to solve this problem?Could any one help me out?
www
|
|
|
|
|
What are you going for?
One way is to empty the textbox.text at postbacks.
If you don't need the value in the textbox at serverside then use a <input type="button" instead.
|
|
|
|
|
Actually i don't want to write any code.
I want to use EnableViewState property. What is the use of it? Have you ever tried it. If so let me know
your name
www
|
|
|
|
|