|
What is the problem.... load the page using Webbrowser control of your windows application and invoke the items which you need to get the querystring...
For example :
Say I add a Webbrowser control on my form,
now during form load I pass
wbrowser.Navigate(new Uri("http://codeproject.com"));
Next I navigate to an article. You might invoke browser buttons to navigate. Finally to get the querystring you use :
wbrowser.Url.Query
I hope this is what you needed.
Next time post in right section.
|
|
|
|
|
Is there any simple code to resize the image in image upload and at the time of showing the image in asp.net.
plz urgent
thanks
|
|
|
|
|
public static string Resize(string InputFilePath, string Name, int TargetWidth, int TargetHeight, string Extension, string TargetFolder)
{
string thumbnailFilePath = string.Empty;
string FileName = string.Empty;
Size newSize;
try
{
using (Bitmap bmp = new Bitmap(InputFilePath))
{
newSize = GetRelativeImageSize(bmp.Width, bmp.Height, TargetWidth, TargetHeight);
FileName = Name + Extension;
thumbnailFilePath = TargetFolder + FileName;
using (Bitmap thumb = new Bitmap((System.Drawing.Image)bmp, newSize))
{
using (Graphics g = Graphics.FromImage(thumb)) // Create Graphics object from original Image
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
//Set Image codec of JPEG type, the index of JPEG codec is "1"
System.Drawing.Imaging.ImageCodecInfo codec = GetImageCodec(Extension);
//Set the parameters for defining the quality of the thumbnail... here it is set to 100%
System.Drawing.Imaging.EncoderParameters eParams = new System.Drawing.Imaging.EncoderParameters(1);
eParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L);
//Now draw the image on the instance of thumbnail Bitmap object
g.DrawImage(bmp, new Rectangle(0, 0, thumb.Width, thumb.Height));
thumb.Save(thumbnailFilePath, codec, eParams);
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return FileName;
}
//it will return the file name with resize.
private static Size GetRelativeImageSize(int SourceWidth, int SourceHeight, int TargetWidth, int TargetHeight)
{
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;
if (SourceWidth <= TargetWidth && SourceHeight <= TargetHeight)
{
return new Size(SourceWidth, SourceHeight);
}
else if (TargetWidth == 0)
{
if (SourceHeight > TargetHeight)
{
nPercentH = ((float)TargetHeight / (float)SourceHeight);
nPercent = nPercentH;
}
else
return new Size(SourceWidth, SourceHeight);
}
else if (TargetHeight == 0)
{
if (SourceWidth > TargetWidth)
{
nPercentW = ((float)TargetWidth / (float)SourceWidth);
nPercent = nPercentW;
}
else
return new Size(SourceWidth, SourceHeight);
}
else
{
nPercentW = ((float)TargetWidth / (float)SourceWidth);
nPercentH = ((float)TargetHeight / (float)SourceHeight);
if (nPercentH < nPercentW)
{
nPercent = nPercentH;
}
else
{
nPercent = nPercentW;
}
}
return new Size(Convert.ToInt32(SourceWidth * nPercent), Convert.ToInt32(SourceHeight * nPercent));
}
Regards
Keyur Satyadev
|
|
|
|
|
thanks for the code
what about the functon of
GetImageCodec(Extension)
you dont declare this function.
|
|
|
|
|
private static ImageCodecInfo GetImageCodec(string Ext)
{
switch (Ext)
{
case ".jpg":
return ImageCodecInfo.GetImageEncoders()[1];
case ".gif":
return ImageCodecInfo.GetImageEncoders()[2];
case ".bmp":
return ImageCodecInfo.GetImageEncoders()[0];
case ".png":
return ImageCodecInfo.GetImageEncoders()[4];
case ".jpeg":
return ImageCodecInfo.GetImageEncoders()[1];
case ".tif":
return ImageCodecInfo.GetImageEncoders()[3];
case ".jpe":
return ImageCodecInfo.GetImageEncoders()[1];
case ".jfif":
return ImageCodecInfo.GetImageEncoders()[1];
case ".tiff":
return ImageCodecInfo.GetImageEncoders()[3];
default:
return ImageCodecInfo.GetImageEncoders()[1];
}
}
Regards
Keyur Satyadev
|
|
|
|
|
Hi!!
I'm trying use this code but does not working.
Please help me.
Simply does not work, not of error but also does not work.
public void carregarImagem()
{
string path = "~/imagens/" + FileUpload1.FileName;
string folder = "~/imagens/";
string nome = FileUpload1.FileName;
int largura = Convert.ToInt32(w.Text);
int altura = Convert.ToInt32(h.Text);
string ext = System.IO.Path.GetExtension(FileUpload1.FileName);
string name = "~/imagens/" + FileUpload1.FileName;
Resize(picImage.ImageUrl, nome, largura, altura, ext, folder);
//used to show image
picImage.ImageUrl = name;
}
|
|
|
|
|
|
I'm tring to use this function "CreateThumbnail", but dosen't work.
Just dont show me nothing.
Please.
|
|
|
|
|
i want to save items in listbox without using data base.how it is possible
|
|
|
|
|
Use "Session" if you want it on multiple page or through out the site.
Regards
Keyur Satyadev
|
|
|
|
|
|
Thats really Basic stuff.. Hope u must start reading a good book....
|
|
|
|
|
Hi,
I am developing a solution using MVC frame work and now I see that I have top heavily depend on the HTML Helper class and I am not using any of the server objects. It takes lot more time to do any thing now wrt server controls.
How can I introduce/use server controls with out breaking the MVC gudelines.
Regards,
Pavas
|
|
|
|
|
i am very new in aspdotnetstorefront and want to change skin of storfront
from manual of aspdotnetstorefront i try to follow steps to change skin but i have to face many problems and still unable to change skin
please guide me how i can change skin
i have html and css pages
Regards
|
|
|
|
|
You have to be familiar with XSLT before you can effectively skin ASPDNSF. Trust me, I've been down that road of hell before.
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
i have read XSLT but still unable to decide how i should start and how should take first step to change skin.
i am trying to change skin of home page and i am working with template.aspx and style.css which are in skin folder
please can you tell me few tips or steps
Thanks
Best Regards
|
|
|
|
|
Ok, here's my problem. I have two pages: one called FirstPage.aspx and the other one called SecondPage.aspx. Here's what I want to do... I start with FirstPage.aspx and here I have a button and when I click it SecondPage.aspx appears. I do that using Response.Redirect("SecondPage.aspx", false). Ok, now when it loads the second page I want to show in a label the name of the first page. How can I do that? If I have used the PostBackUrl property of the button from the first page, this would have been easy. I would have written in the SecondPage:
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
if (PreviousPage != null)<br />
{<br />
Label1.Text = PreviousPage.Title;<br />
}<br />
<br />
}<br />
But, I need to show the second page using Response.Redirect("SecondPage.aspx", false). So any help?
|
|
|
|
|
Just pass the value using Querystring...
Do like this when you navigate to the second page:
Response.Redirect("secondpage.aspx?name=" + pagename);
After you redirect, you will find the value of name easily.
In Page_load :
protected void Page_Load(object sender, EventArgs e)
{
string firstpagename = Request.QueryString["name"];
Label1.Text = firstpagename;
}
I think this is what you needed.
Cheers.
|
|
|
|
|
I am using AJAX control toolkit Accordion control on my page.
In accordion pane i have added one pane and in that pane i put some header and content. My code below shows for header and content
<Header>
<div style="float: left; width: 100%;" class="head4">
1. Household Size</div>
</Header>
<Content>
<div style="float: left; width: 50%; background-color: #a9d4ff;">
<asp:Label ID="lbl_Stud_HouseholdSize" runat="server" Text="5"></asp:Label>
</div>
<div style="float: left; width: 50%; background-color: #afffaf;">
<asp:Label ID="lbl_Parent_HSize" runat="server" Text=""></asp:Label></div>
<div style="float: left; width: 50%; background-color: #a9d4ff;">
<div style="float: left; width: 100%;">
<asp:RadioButtonList ID="rd_Shouseholdsize" runat="server" RepeatDirection="Horizontal"
Width="70px" AutoPostBack="True" OnSelectedIndexChanged="rd_householdsize_SelectedIndexChanged">
<asp:ListItem Value="1">Valid</asp:ListItem>
<asp:ListItem Value="0">Correction</asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
</Content>
The problem is when i execute, it does not show anything in pane. Just show the headers.
Any solution will be helpfull.
|
|
|
|
|
look at below link you will get the solution.
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Accordion/Accordion.aspx
Regards
Keyur Satyadev
|
|
|
|
|
Here's a sample that works for me. This is one of my accordian snippets from an Ajax-enabled web project. Take a look - you might see something that you have missed. Also, check your CSS - make sure you don't have bugs in there - something that might be hiding a div for example.
<ajaxToolkit:Accordion ID="ajax_acc_Reports" runat="server"
HeaderCssClass="accordionheader" HeaderSelectedCssClass="accordionheader-selected"
SelectedIndex="-1" AutoSize="None" FadeTransitions="true" TransitionDuration="250"
FramesPerSecond="40" RequireOpenedPane="false" SuppressHeaderPostbacks="true">
<Panes>
<ajaxToolkit:AccordionPane ID="apnAnalysis" runat="server" ContentCssClass="accordionpane-selected">
<Header><strong>Analysis</strong></Header>
<Content>
<ul><li><a href="Reports/Analysis/July_09.pdf" title="QA July 09 Report"
target="_blank">QA July 09 Report</a></li></ul>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>
Please let me know if this does or does not help you
|
|
|
|
|
Here's my problem: I have a button and when I click it I want to open a new page. I know that I can do this thing very easy by setting the PostBackUrl property of the button. But here's what I want to do: on my page I have a textbox and, for example when I press the button I want to test the text from the TextBox and if it's ok I want to show the new page; if not I want to display a message. I want to do that using c# language, and not JavaScript. I've tried this:
<br />
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
if (TextBox1.Text == "something")<br />
Button1.PostBackUrl = "NewPage.aspx";<br />
else<br />
....................<br />
<br />
}<br />
<br />
Ok, everithing is fine until now. But when I press the button, assuming that in my textbox I've written "something", the NewPage isn't displayed. My current page is loaded again and when I press the button again then NewPage.aspx is displayed. And I don't know why this is happening.
Can anyone help me please?
|
|
|
|
|
Try:
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "something")
{
Response.Redirect("NewPage.aspx");
}
else
{
....................
}
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
I think he wants to "Postback" to a new page and not re-direct to a new page.
|
|
|
|
|
The Postback url defaults to the current page and this is where your first click will return to, because, at this first click point your browser doesn't know to postback to NewPage.aspx. Only on the second click (after you've set Button1.PostBackUrl = "NewPage.aspx") will you get postback to the new page.
IF YOU NEED TO POSTBACK TO A DIFFERENT PAGE THEN....
you can't avoid using javascript. Setting PostBackUrl on the server won't affect the current request (your first click).
IF YOU'RE NOT REALLY CONCERNED WITH POSTBACK THEN....
do what the other guys suggested and replace the Button1.PostBackUrl = "NewPage.aspx" with the ReDirect, or Server.Transfer("NewPage.aspx"); code.
|
|
|
|