|
I have a question.. I am trying to add items to a dropdownlist or select box and then when someone pushes the submit button (ASP.net button) it gets the list of items.
The problem is it doesn't work like that. It doesn't see any of the items. What I am doing is populating one dropdownlist with peoples names and email addresses from active directory (name == text, email == value). When you select the name and click add (HTML button) it adds the email to my other dropdownlist with javascript:
function btnAddEmail_onclick() {
var cbCCEmails = document.getElementById("cbCCEmails");
var dropUserEmails = document.getElementById("<%= dropUserEmails.ClientID %>");
var SelectedIndex = dropUserEmails.selectedIndex;
var Email = dropUserEmails(SelectedIndex).value;
var Name = dropUserEmails(SelectedIndex).text;
if (SelectedIndex != -1)
{
cbCCEmails.options.add(new Option(Email, Name));
dropUserEmails.remove(SelectedIndex);
}
}
Now the code you see above takes the name from one box and adds the email to another one (cbCCEmails).
Now in the code behind im trying to loop through each ListItem. What I am tryign to do is CC all the emails in that listbox:
for (int i = 0; i < cbCCEmails.Items.Count; i++)
{
if (String.IsNullOrEmpty(CCEmails))
CCEmails = cbCCEmails.Items[i].Text;
else
CCEmails += "," + cbCCEmails.Items[i].Text;
mm.CC.Add(new MailAddress(cbCCEmails.Items[i].Text));
}
Please ignore the CCEmails string.. that is used for inserting into a database.
I understand that i am losing the values on postback beacuse of the button, but how do I retain those values? ViewState is enabled but autopostback is not since im adding it with javascript. Teh reason I am using javascript on that side is because posting back takes to long and is slow
|
|
|
|
|
Use hidden variables for your scenario.Assign the values from javascript and you'll able to access from codebehind also.
Cheers!!
Brij
|
|
|
|
|
I'm more of a windows developer.. so I take it hidden variables is saving the results to one textbox or something?
So each time someone adds the email, append it to a textbox, then on the postback get the items from the textbox and split it by a comma (if that is how I seperated them)?
|
|
|
|
|
I can't find wizard control in tool box [Visualstudio2008].
I have already added it but not showing in my tool box.
please advice
|
|
|
|
|
See the following.It might be of help
Click here
Cheers!!
Brij
|
|
|
|
|
He is talking abt Web Application And You are talking abt Windows application..! check your answer..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
You No need To add it will come under Login Controls..!If it not there u need to repair the Visual studio..!
You are talking abt web application right?
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Originally I had planned to use Dreamweaver CS4 for general website design, layout, and master pages (and then transfer into VWD, but after watching several awesome tutorial videos on designing website using Visual Studio 2008, I want to give VWD a try before jumping to Dreamweaver.
Then there's Adobe Fireworks, though designed to function very well with Dreamweaver, seems to be a great tool in its own right. My question is how well does Adobe Fireworks works with Visual Studio 2008? Or is there a graphic designer out there that goes along better with VWD?
I'd greatly appreciate for any suggestions.
Thanks!
|
|
|
|
|
Fireworks is simply a graphics package (or at leats it used to be) which is used to generate images. This has absolutely nothing to do with the tools you use to design your web pages. What graphics tool you use is down to persobal choice, at the end of the day they just create images.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hello friends,
I want to access C# dll functions from javascript. Can any one tell me steps to do it?
Thanks
Amit
|
|
|
|
|
You can do it using ActiveX Components. But this will work only on IE .
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
If you use Ajax you can make calls to a web host if the C# dll accepts post request, you can translate your requests through an ASP.NET page, or if you use Silverlight you can interact with silverlight from Javascript. Each choice has pro's and con's.
If you really want seamless interaction, use Java and Live Connect.
|
|
|
|
|
Create one HttpHandler, in that reference the dll and do all you need in ProcessRequest.
From javascript, call the handler to fetch the response.
If you want to use Javascript to access WebMethod, you can also do that using PageMethod, for which you need to expose the methods as Web Service.
Take a look into this :
http://forums.asp.net/p/1266663/2382644.aspx[^]
|
|
|
|
|
Hi experts ,
Is there any way to use "System.Web.UI.ScriptManager" in FW2.0..is there any alternative control for this ?
|
|
|
|
|
I think if you install AJAX framework, it will work in Framework 2.0...
|
|
|
|
|
Hi, I have to download a doc file and show the pdf file in the browser. For that I have used the following code in JavaScript of the button click
window.open(url, 'Download', 'height=1,width=1,top=0,left=-1000');
where url represent the path of the file (http://localhost/website/filename.doc).I do not want to show the popup window, for that I have used left=-1000, but it does not effect. Do you have any idea how I can hide that popup window
Pankaj
|
|
|
|
|
Does anyone have the solution
Pankaj
|
|
|
|
|
Hey, I have created following code. But button event is not firing. Please look at the code and tell me where I am doing wrong.
namespace immu.control
{
[ToolboxData("<{0}:myControl runat=server></{0}:myControl>")]
public class docControl : WebControl
{
public Button btn;
protected override void CreateChildControls()
{
Panel pnl = new Panel();
btn = new Button();
btn.Text = "Click Me";
btn.Click += new EventHandler(btn_Click);
pnl.Controls.Add(btn);
this.Controls.Add(pnl);
}
public void btn_Click(object sender, EventArgs e)
{
HttpContext.Current.Response.Redirect("http://google.com");
}
}
}
Thanks.
Imrankhan
please don't forget to vote on the post that helped you.
|
|
|
|
|
The problem is solved.
Thanks.
please don't forget to vote on the post that helped you.
|
|
|
|
|
Hi,
I am working on ASP.NET(c#)/SQL Server project. I my project i want to have the textbox to show the text like the text in "SQL Script".
e.g: When we write the query in sql Server the color of reserved words (like "select", "where" etc) changes to blue, the color of commented lines changes to green and the other text remains the same.
Please guide me how to do this.
Sonia
|
|
|
|
|
Create a list of reserved words, and as the user types in check the word against your list and colour appropriately.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
How can i use different colors in a single textbox.
|
|
|
|
|
It was a trick answer. Of course you can't, you need to put it into some other sort of control, say a div, and you will have to do it in javascript unless you want to post back to the server each time. Now use you initiative and google, there are loads of examples
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
You can not do it in TextBox, You have to use div element. On keypress event, you have to call javascript function where you need to read all string of div by splinting space and check if word are in listing then add font attribute or span attribute around word and set style.
Search in google for how to write on div element.
Regard
Imrankhan
please don't forget to vote on the post that helped you.
|
|
|
|
|
I do not have too much knowledge of javascript. Please tell me the solution in c#.
|
|
|
|