Home » Applications » ASP.NET » Archive by category "Controls" (Page 2)

Archive for the 'Controls' Category

Captcha – VB.NET

Email form <tr> <td></td> <td></td> </tr> <tr> <td></td> <td><img style=”WIDTH: 119px; HEIGHT: 34px” alt=”” src=”Captcha.aspx” />  <a href=””>Can’t Read?</a></td> </tr> <tr> <td></td> <td><asp:textbox runat=”server” ID=”txtcaptcha”></asp:textbox></td> </tr> <tr> <td></td> <asp:ImageButton ID=”ContactSeller” CausesValidation=”True” runat=”server” ImageURL=”/images/buttons/btn_submit.gif” /></td> </tr> Email page code behind …. Dim captchaStr As String = Session(“randomStr”) Dim captchaTxt As TextBox = ContactSeller.FindControl(“txtcaptcha”) If captchaStr captchaTxt.Text.ToString […]

Add item on the dropdownlist – VB.NET

Markup page <!– ‘define control –> <asp:DropDownList ID=”MySelectionDDL” runat=”server” AutoPostBack=”True” AppendDataBoundItems=”true” DataSourceID=”MySelectionDS” DataTextField=”Text” DataValueField=”Value” OnDataBound=”MySelectionDDL_DataBound”> <!– ‘define datasource –> <asp:SqlDataSource ID=”MySelectionDS” runat=”server” ConnectionString=”< %$ ConnectionStrings:my_sql_connection %>” SelectCommand=”SELECT [Text], [Value] FROM [MyTable] ORDER BY [Text]”> </asp:SqlDataSource> Code behind Protected Sub MySelectionDDLDataBound(ByVal sender As Object, ByVal e As EventArgs) ‘add item at the beginning of the list […]

Define control properties in code behind located inside gridview or formview

Markup page <asp:FormView ID=”DefaultPhoto” runat=”server” DataKeyNames=”ge_id” DataSourceID=”ListPhotosDS”> <EditItemTemplate> <img src=”/images/< %# Container.DataItem("photo") %>” class=”detailsmallphoto”/> <asp:Label ID=”photo_idLabel” runat=”server” Text=’< %# Eval("photo_id") %>‘ Visible=”false” /> <asp:LinkButton ID=”UpdateButton” runat=”server” OnClientClick=”return confirm(‘Are you sure you want to remove this photo?’);” CommandName=”Update” /> </EditItemTemplate> </asp:FormView> Code behind DirectCast(DefaultPhoto.FindControl(“UpdateButton”), LinkButton).Text = “Remove” If Page.isPostBack Then DirectCast(DefaultPhoto.FindControl(“UpdateButton”), LinkButton).Text = “Add Photo” End […]