Monday 15 September 2014

asp.net - send email from listview button -



asp.net - send email from listview button -

i have made listview fetching email id of client . there button send mail service selected column. don't know how please help me. code working now..

imports scheme imports system.data imports system.data.sqlclient imports system.configuration partial class dashboard inherits system.web.ui.page dim con new sqlconnection("data source=suraj;initial catalog=brandstik2; integrated security=true") dim comp_id, client_name string protected sub add_company_click(byval sender object, byval e system.eventargs) handles add_company.click add_client.visible = true headings.text = "add new companies" end sub protected sub page_load(byval sender object, byval e system.eventargs) handles me.load if not me.ispostback me.bindlistview() end if add_client.visible = false send_request_form.visible = false headings.text = "dashboard" 'dim str1 string = "select * brandstiktesti" 'dim cmd1 new sqlcommand(str1, con) 'con.open() 'dim rdr1 sqldatareader = cmd1.executereader 'while rdr1.read ' label1.text = rdr1(0) ' label2.text = rdr1(1) 'end while 'con.close() 'rdr1.close() 'cmd1.dispose() end sub protected sub send_request_click(byval sender object, byval e system.eventargs) handles send_request.click add_client.visible = false send_request_form.visible = true headings.text = "send feedback request" success.visible = false end sub protected sub submit_client_click(byval sender object, byval e system.eventargs) handles submit_client.click dim comp_id, client_name, email_id string form1.visible = true comp_id = textbox1.text client_name = textbox2.text email_id = textbox3.text textbox1.text = "" textbox2.text = "" textbox3.text = "" seek dim str1 string = "insert brandstiktesti(comp_id, client_name, email_id) values ('" + comp_id + "', '" + client_name + "', '" + email_id + "')" con.open() dim cmd new sqlcommand(str1, con) cmd.executenonquery() con.close() grab ex exception response.write("this id exist") end seek success.text = "client added succesfully" end sub private sub bindlistview() dim con new sqlconnection("data source=suraj;initial catalog=brandstik2; integrated security=true") using cmd new sqlcommand() cmd.commandtext = "select comp_id, client_name, email_id brandstiktesti" cmd.connection = con using sda new sqldataadapter(cmd) dim dt new datatable() sda.fill(dt) lvcustomers.datasource = dt lvcustomers.databind() end using end using end sub end class

how can select emaild id on button click of listview & send mail service on particular mail service id.

when asp.net element post server, beingness done using asp's premade javascript function __dopostback :

<script> function __dopostback( eventtarget, eventargument ) { document.form1.__eventtarget.value = eventtarget; document.form1.__eventargument.value = eventargument; document.form1.submit(); } </script>

if want pass html listview element code behind, can intercept button click , submit email_id in __eventargument argument thats beingness sent server.

for example, can run javascript function on asp.net button click, prior posting using onclientclick:

<asp:button id="bt_send" runat="server" text="send" onclick="bt_send_click" onclientclick="submit_stuff" /> function submit_stuff(){ //get email id here var _email_id = "blablabla1"; //manually cause postback email id argument __dopostback('<%=bt_send.clientid%>',_email_id ); homecoming false; }

and in code behind, either on page load or on bt_send_click function retrieve argument:

dim email_id string = request.form("__eventargument")

asp.net vb.net

No comments:

Post a Comment