Showing posts with label attribute. Show all posts
Showing posts with label attribute. Show all posts

Monday, March 26, 2012

HTML Form value retrieval

Yes. If you use the action attribute, it works fine. Here's an example, from
this working page
http://www.pmaconference.com/specia...04/register.htm

<form name="form" onsubmit="return(sendReg())"
action="https://energycatalogue.acomhosting.com/orderform.aspx"
"Matt" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:F7ED5A87-B31F-4BA8-A0A2-CFC966462174@dotnet.itags.org.microsoft.com...
> I have an aspx page whose purpose is to read a customer-provided HTML
form, display it, and reads the values from it on a postback. I cannot seem
to read the values from Request.Form when this type of form is posted back.
All I am trying to do is loop through the items in Request.Form and store
their values for later use in the application. Neither the "form" tag nor
the control tags use the runat="server" attribute since this is a
customer-created form that we would like to be standard HTML to allow full
control of the form contents, and look and feel of the form. There will
only ever be one client-side form per rendering of the page. By adding the
runat="server" attribute to the form tag, I have been able to see only one
item in the Request, _VIEWSTATE. None of the other HTML controls will
appear in the collection. Is this type of thing possible?Thanks for the reply. Even with the action on the form, I the Request.Form.Count value is also zero when I do a postback. Obviously there's something wrong, probably very basic. Below is the form that I am testing with. I've tried with and without the METHOD and ACTION attributes

<form name="autos" method="post" action="http://cregosource/privateparty/formdata.aspx"><input type="checkbox" id="check" value="checkvalue"><br><input type="checkbox" id="check2" value="checkvalue2"><br><input type="text" id="text" value="333333"><textarea id="mytextarea">asdf</textarea><input type="radio" id="myradio" value="1"><input type="radio" id="myradio" value="2"><input type="radio" id="myradio" value="3"><select id="myselect" size="5"><option>1</option><option>2</option></select><select id="myselectmultiple" size="5" multiple><option value="1">one</option><option value="2">two</option><option value="3">three</option><option value="4">four</option><option value="5">five</option></select><br><br><input type="submit" value="Submit"></form

And here's the code in a codebehind page that I'm debugging

if (Request.Form.Count>0)

foreach (string strReq in Request.Form)

oTrans.KeyAddOrReplace(PrivateParty.TranState.Sect ionType.Form,strReq,Request[strReq])

oTrans.SaveState()

Even if I omit the Count test, there are no items in the Form. Does it pose a problem if I am using usercontrols on this page? I do not specifically call out any form tags in these controls. Any additional help is much appreciated!

Html form trouble

Hi,
On my asp.net page I have an html form. I've set runat attribute to server
and filled it with server controls. All settings
are as I like them.
So here's the problem: when I perform a search for the first time, everythin
g works perfectly. If I make any changes to the
controls in the form and resubmit the page, nothing changes. That is, viewi
ng the querystring, not a single value is altered
despite my doing so in the form itself.
Is there some problem with the html form? I can't for the life of me figure
this out. Any help would be greatly appreciated.
Thanks,
RoshawnHi,
Roshawn wrote:
> Hi,
> On my asp.net page I have an html form. I've set runat attribute to
> server and filled it with server controls. All settings are as I like
> them.
> So here's the problem: when I perform a search for the first time,
> everything works perfectly. If I make any changes to the controls in
> the form and resubmit the page, nothing changes. That is, viewing the
> querystring, not a single value is altered despite my doing so in the
> form itself.
> Is there some problem with the html form? I can't for the life of me
> figure this out. Any help would be greatly appreciated.
> Thanks,
> Roshawn
We'll need to see some code. Please post an extract of your code able to
reproduce the problems, stripping what is not necessary.
Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Hi Laurent. Sorry for the delayed response, been busy. As you requested, h
ere's some code.
HTML Form
<form runat="server" enableviewstate="false">
<label for="q">Search:</label><br/>
<input type="text" name="q" id="q" maxlength="100" /><br/>
<label for="sz">Shoe Size:</label><br/>
<asp:dropdownlist id="sz" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="42802">5 & Smaller</asp:listitem>
<asp:listitem value="37090">6</asp:listitem>
<asp:listitem value="22806">7</asp:listitem>
<asp:listitem value="1032">8</asp:listitem>
'more listitems go here
</asp:dropdownlist><br/>
<label for="tp">Type:</label><br/>
<asp:dropdownlist runat="server" id="tp" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="2293">Athletic</asp:listitem>
<asp:listitem value="31920">Athletic-Inspired</asp:listitem>
</asp:dropdownlist><br/>
<label for="cd">Condition:</label><br/>
<asp:dropdownlist id="cd" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="31919">New</asp:listitem>
</asp:dropdownlist><br/>
<input type="submit" id="submit" value="Search" />
</form>
Code to handle form (note that this uses the eBay XML API; it works as expec
ted and is called in the Page_Load event)
Private Sub GetShoeResults()
Dim hp As New MyHelper() 'declared variable for the MyHelper class for auxil
lary functions
Dim shoe As Shoe = New Shoe()'custom class
Dim sb As New StringBuilder("<?xml version=""1.0"" encoding=""utf-8""?>")
With sb
.Append("<GetSearchResultsRequest xmlns=""urn:ebay:apis:eBLBaseComponents"">
<RequesterCredentials><eBayAuthToken>" &
ConfigurationManager.AppSettings("Token") & "</eBayAuthToken></RequesterCred
entials>")
.Append("<CategoryID>63850</CategoryID><DetailLevel>ReturnAll</DetailLevel>"
)
If Request.QueryString("q") <> "" Then
.Append("<Query>" & Request.QueryString("q") & "</Query>")
End If
.Append("<SearchRequest><AttributeSetID>22</AttributeSetID><ProductFinderID>
22</ProductFinderID>")
'for the Size Parameter
If Request.QueryString("sz") <> "" Then
'turn off all selected items
For i = 0 To Me.sz.Items.Count - 1
Me.sz.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>53</AttributeID><ValueList><ValueID>
" & Request.QueryString("sz") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.sz.Items
If item.Value = Request.QueryString("sz") Then
shoe.Size_ID = item.Value
shoe.Size = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Type Parameter
If Request.QueryString("tp") <> "" Then
'turn off all selected items
For i = 0 To Me.tp.Items.Count - 1
Me.tp.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>54</AttributeID><ValueList><ValueID>
" & Request.QueryString("tp") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.tp.Items
If item.Value = Request.QueryString("tp") Then
shoe.Type_ID = item.Value
shoe.Type = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Condition Parameter
If Request.QueryString("cd") <> "" Then
'turn off all selected items
For i = 0 To Me.cd.Items.Count - 1
Me.cd.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>94</AttributeID><ValueList><ValueID>
" & Request.QueryString("cd") &
"</ValueID></ValueList></SearchAttributes>")
Dim item2 As ListItem
For Each item2 In Me.cd.Items
If item2.Value = Request.QueryString("cd") Then
shoe.Condition_ID = item2.Value
shoe.Condition = item2.Text
item2.Selected = True
Exit For
End If
Next
End If
'Add Pagination in case a page number is returned in the querystring
.Append("<Pagination><EntriesPerPage>10</EntriesPerPage></Pagination></GetSe
archResultsRequest>")
End With
Try
Me.Xml1.DocumentContent = hp.CreateHeaders(sb.ToString())'call to eBay
Dim ext As New XsltArgumentList()
ext.AddExtensionObject("urn:Shoes", shoe)
Me.Xml1.TransformArgumentList = ext
Me.Xml1.TransformSource = "search.xslt"
Catch ex As WebException
'handle errors here
End Try
End Sub
I hope this helps you help me. Thanks for being interested. :-)
Roshawn

Html form trouble

Hi,

On my asp.net page I have an html form. I've set runat attribute to server and filled it with server controls. All settings
are as I like them.

So here's the problem: when I perform a search for the first time, everything works perfectly. If I make any changes to the
controls in the form and resubmit the page, nothing changes. That is, viewing the querystring, not a single value is altered
despite my doing so in the form itself.

Is there some problem with the html form? I can't for the life of me figure this out. Any help would be greatly appreciated.

Thanks,
RoshawnHi,

Roshawn wrote:

Quote:

Originally Posted by

Hi,
>
On my asp.net page I have an html form. I've set runat attribute to
server and filled it with server controls. All settings are as I like
them.
>
So here's the problem: when I perform a search for the first time,
everything works perfectly. If I make any changes to the controls in
the form and resubmit the page, nothing changes. That is, viewing the
querystring, not a single value is altered despite my doing so in the
form itself.
>
Is there some problem with the html form? I can't for the life of me
figure this out. Any help would be greatly appreciated.
>
Thanks,
Roshawn


We'll need to see some code. Please post an extract of your code able to
reproduce the problems, stripping what is not necessary.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Hi Laurent. Sorry for the delayed response, been busy. As you requested, here's some code.

HTML Form
<form runat="server" enableviewstate="false">
<label for="q">Search:</label><br/>
<input type="text" name="q" id="q" maxlength="100" /><br/>
<label for="sz">Shoe Size:</label><br/>
<asp:dropdownlist id="sz" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="42802">5 & Smaller</asp:listitem>
<asp:listitem value="37090">6</asp:listitem>
<asp:listitem value="22806">7</asp:listitem>
<asp:listitem value="1032">8</asp:listitem>
'more listitems go here
</asp:dropdownlist><br/>
<label for="tp">Type:</label><br/>
<asp:dropdownlist runat="server" id="tp" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="2293">Athletic</asp:listitem>
<asp:listitem value="31920">Athletic-Inspired</asp:listitem>
</asp:dropdownlist><br/>
<label for="cd">Condition:</label><br/>
<asp:dropdownlist id="cd" runat="server" enableviewstate="false">
<asp:listitem value="-24">Any</asp:listitem>
<asp:listitem value="31919">New</asp:listitem>
</asp:dropdownlist><br/>
<input type="submit" id="submit" value="Search" />
</form>

Code to handle form (note that this uses the eBay XML API; it works as expected and is called in the Page_Load event)
Private Sub GetShoeResults()
Dim hp As New MyHelper() 'declared variable for the MyHelper class for auxillary functions
Dim shoe As Shoe = New Shoe()'custom class
Dim sb As New StringBuilder("<?xml version=""1.0"" encoding=""utf-8""?>")
With sb
.Append("<GetSearchResultsRequest xmlns=""urn:ebay:apis:eBLBaseComponents""><RequesterCredentials><eBayAuthToken>" &
ConfigurationManager.AppSettings("Token") & "</eBayAuthToken></RequesterCredentials>")
.Append("<CategoryID>63850</CategoryID><DetailLevel>ReturnAll</DetailLevel>")
If Request.QueryString("q") <"" Then
.Append("<Query>" & Request.QueryString("q") & "</Query>")
End If
.Append("<SearchRequest><AttributeSetID>22</AttributeSetID><ProductFinderID>22</ProductFinderID>")
'for the Size Parameter
If Request.QueryString("sz") <"" Then
'turn off all selected items
For i = 0 To Me.sz.Items.Count - 1
Me.sz.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>53</AttributeID><ValueList><ValueID>" & Request.QueryString("sz") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.sz.Items
If item.Value = Request.QueryString("sz") Then
shoe.Size_ID = item.Value
shoe.Size = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Type Parameter
If Request.QueryString("tp") <"" Then
'turn off all selected items
For i = 0 To Me.tp.Items.Count - 1
Me.tp.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>54</AttributeID><ValueList><ValueID>" & Request.QueryString("tp") &
"</ValueID></ValueList></SearchAttributes>")
Dim item As ListItem
For Each item In Me.tp.Items
If item.Value = Request.QueryString("tp") Then
shoe.Type_ID = item.Value
shoe.Type = item.Text
item.Selected = True
Exit For
End If
Next
End If
'for the Condition Parameter
If Request.QueryString("cd") <"" Then
'turn off all selected items
For i = 0 To Me.cd.Items.Count - 1
Me.cd.Items(i).Selected = False
Next
.Append("<SearchAttributes><AttributeID>94</AttributeID><ValueList><ValueID>" & Request.QueryString("cd") &
"</ValueID></ValueList></SearchAttributes>")
Dim item2 As ListItem
For Each item2 In Me.cd.Items
If item2.Value = Request.QueryString("cd") Then
shoe.Condition_ID = item2.Value
shoe.Condition = item2.Text
item2.Selected = True
Exit For
End If
Next
End If
'Add Pagination in case a page number is returned in the querystring
.Append("<Pagination><EntriesPerPage>10</EntriesPerPage></Pagination></GetSearchResultsRequest>")
End With
Try
Me.Xml1.DocumentContent = hp.CreateHeaders(sb.ToString())'call to eBay
Dim ext As New XsltArgumentList()
ext.AddExtensionObject("urn:Shoes", shoe)
Me.Xml1.TransformArgumentList = ext
Me.Xml1.TransformSource = "search.xslt"
Catch ex As WebException
'handle errors here
End Try
End Sub

I hope this helps you help me. Thanks for being interested. :-)

Roshawn

html encoding?

Hi,
I am trying to add a "src" attribute to an iframe by code as follows:
this.MyWin.Attribute.Add("src","page1.aspx?par1=1&par2=2");

But the output page always convert the '&" into &
How can I avoid this convertion?ThanksTry eitherHtmlEncode orHtmlDecode

Thursday, March 22, 2012

HTML control Vs Web form control

Hi,

I am new to asp.net. I want to know that, HTML and Web form control can work
in same way example, using "runat = Server" attribute, html control can also
executed at server, then what is the use of HTML control and is there is any
specific condition when we use only HTML control or web form control.

Thanks and regards,
Bhuwan"Bhuwan Bhaskar" <kxxx@.gmail.comwrote in message
news:uxe%23IJ4HIHA.4560@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

I am new to asp.net. I want to know that, HTML and Web form control can
work in same way example, using "runat = Server" attribute, html control
can also executed at server, then what is the use of HTML control and is
there is any specific condition when we use only HTML control or web form
control.


http://www.google.co.uk/search?sour...ls+HTMLControls
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Html controls are lighter. One of typical scenarios where you may want to
use html controls is when you have an html prototype of your page and you
need to program it in asp.net. Then it is easier just to add runat=server to
html controls.

Web controls offer common set of server-side members that can make your code
cleaner and more readable.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Bhuwan Bhaskar" <kxxx@.gmail.comwrote in message
news:uxe%23IJ4HIHA.4560@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Hi,
>
I am new to asp.net. I want to know that, HTML and Web form control can
work in same way example, using "runat = Server" attribute, html control
can also executed at server, then what is the use of HTML control and is
there is any specific condition when we use only HTML control or web form
control.
>
Thanks and regards,
Bhuwan
>

html control and webserver control

in asp.net 1.1

we have html controls and webserver controls

For html controls, if we set the attribute called runat="server", then will that html control turn in webserver control?

then what is the use of having two different catogeries?

Putting a runat="server" in html controls will make them html server controls. The difference between these are that you can only do client-side scripting with HTML Controls whereas with HTML server controls or webserver controls you can control them via server side or client side scripting. HTML controls are basically not being processed by the server itself so their state are not kept across page loads so you can find that these controls render much faster compared to server controls.

Don't know much about why they included HTML server controls but I guess MS wanted to make it easy for developers to move older applications to .NET. It'd be too much of a hassle to start from scratch all over again. This way you can just add a runat="server" attribute to HTML controls.

Web server controls are classes that makes it easier for developers to make controls that look similar to winforms UI which if one would make in pure html code would take quite a while like the datagrid for example. These controls are also being rendered to the client as html controls. Very useful if you would like to have control over customization of your UI.


if we add runat=server attribute to html standard controls then it will become html server controls.One way this is going to useful in conversion projects like from asp to asp.net.More over some of the web server controls(eg calendar ,etc) are more sophisticated as well as rich UI which u cant find in standard html controls.

Below is a link which will give you a good idea about the difference between

Html Controls VS web server controls

HC

-----

Mark it as answered if it helped you