asp.net - Making changes to a pre-populated textbox -
i have following webform textboxes pre-populated on page load:
<%@ page title="" language="vb" masterpagefile="~/default.master" autoeventwireup="true" codefile="admin.aspx.vb" inherits="admin" theme="g2m" %> <asp:content id="content1" contentplaceholderid="head" runat="server"> </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder1" runat="server"> <form id="form1" runat="server"> <label>username: </label> <asp:textbox id="textbox1" runat="server"></asp:textbox> <br /> <label>password: </label> <asp:textbox id="textbox2" runat="server"></asp:textbox> <br /> <label>product type: </label> <asp:textbox id="textbox3" runat="server"></asp:textbox> <br /> <label>smtp default only: </label> <asp:textbox id="textbox4" runat="server"></asp:textbox> <br /> <label>logo: </label> <asp:textbox id="textbox5" runat="server"></asp:textbox> <br /> <asp:button id="submit" text="submit changes" runat="server" onclick="submitchanges" /> </form> </asp:content>
and codebehind follows:
protected sub page_load(byval sender object, byval e system.eventargs) handles me.load dim xmldoc new xmldocument xmldoc.load(server.mappath("~/xml_config/config.xml")) dim configvalues xmlparser = new xmlparser(xmldoc) ''instantiate xmlparser ''populate textboxes xml data textbox1.text = configvalues.username textbox2.text = configvalues.password textbox3.text = configvalues.producttype textbox4.text = configvalues.smtpdefaultonly textbox5.text = configvalues.logo end sub public sub submitchanges(byval sender object, byval e system.eventargs) dim xmldoc new xmldocument xmldoc.load(server.mappath("~/xml_config/config.xml")) dim configvalues xmlparser = new xmlparser(xmldoc) ''instantiate xmlparser configvalues.smtpdefaultonly = textbox4.text end sub
all i'm trying make values editable when form presented user, can change values , submit them file. problem when submitchanges function called, though change value of textbox, still same. how pass new value, typed thetextbox, function?
enclose setter in if not ispostback in page load. it's overwriting boxes.
Comments
Post a Comment