|
You want to open a new browser window and show the google search result or you want to do a google search and display the results in a place holder?
Former can be achieved by opening a new window with url
http://www.google.com/search?hl=en&q=your+search+text+here
To do the latter you need to create a HTTPRequestResponse object and post a request to google server, get the response and display it in the placeholder.
|
|
|
|
|
I want to do the first one i.e. retrieve the text from the search text box to the new browser window which is google.com.
I tried it "www.google.com/search?..." but it doesn't work .is there any alternative or can u understand the code below::
protected void Button1_Click(object sender, EventArgs e)
{
if (tbMainSearch.Text != null || tbMainSearch.Text != "")
{
Response.Redirect("http://www.google.com");
}
else
{
tbMainSearch.Focus();
}
}
The above code is done on clicking the "search" button.
the script is :
<asp:content id="Content2" runat="server"
="" contentplaceholderid="ContentPlaceHolder1">
<asp:textbox id="tbMainSearch" runat="server" style="margin-left: 0px" width="170px" ><="" asp:textbox="" >
="" &nbsp;<asp:button="" text="SEARCH" borderstyle="None"
="" font-bold="True" onclick="Button1_Click">
inderstand and reply back
|
|
|
|
|
I'm able to achieve what you need with this code!
private void Button1_Click(object sender, System.EventArgs e)
{
String SearchString = String.Empty;
if (TextBox1.Text != null || TextBox1.Text != "")
{
SearchString = TextBox1.Text.Replace(" ", "+");
Response.Redirect("http://www.google.com/search?hl=en&q="+SearchString);
}
}
|
|
|
|
|
|
You don't need to post your message to the server to redirect to Google! Use the window.Location.href from javascript to redirect from the browser like so
window.location.href = 'http://www.google.com/search?hl=en&q='+ document.getElementById('TextBox1').value.replace(/ /g,"+");
|
|
|
|
|
Just Try with this :
<html>
<body>
<form action="http://www.google.com/search" method="get">
<input name="q" type="text">
<input type="submit" value="search">
</form>
</body>
</html>
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I want to retrieve the text from the search text box to the new browser window which is google.com.
I tried "www.google.com/search?..." but it doesn't work .is there any alternative or can u understand the code below::
protected void Button1_Click(object sender, EventArgs e)
{
if (tbMainSearch.Text != null || tbMainSearch.Text != "")
{
Response.Redirect("http://www.google.com");
}
else
{
tbMainSearch.Focus();
}
}
The above code is done on clicking the "search" button.
The script is :
<asp:content id="Content2" runat="server"
="" contentplaceholderid="ContentPlaceHolder1">
<asp:textbox id="tbMainSearch" runat="server" style="margin-left: 0px" width="170px" &gt;&lt;="" asp:textbox="" &gt;
="" &amp;nbsp;&lt;asp:button="" text="SEARCH" borderstyle="None"
="" font-bold="True" onclick="Button1_Click">
Understand and reply back
|
|
|
|
|
Hi all,
After being binded, my datagridview is so long, because the there is so much data in the table related, so I want to limit the height of my gridview. Maybe it has a certain height and to see more data, we should use a scroll bar.
Would you give me any suggestion?
|
|
|
|
|
Member 4704143 wrote: my datagridview is so long, beca
Are you talking abt windows application?
this in not the right forum..!
google[^]
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Put your gridview in a div tag and set the height of the that div.
Also make style overflow:auto or scroll.
|
|
|
|
|
|
|
Hi!
I ran into a bit of a problem. I have managed to successfully Create a row of 7 textboxes in a Table at runtime. I used the CalendarExtender on the first Textbox and it works perfect. The trouble begins when I click the "ADD" button to create a new row of 7 Textboxes. I have set the calendarExtender targetId = "txtCalendar" + j meaning that the targetID is txtCalendar0. When I hit the "ADD" button to create a second row I get the error that the TargetId has to be unique.
I understand that I am currently targeting the txtCalendar0 textbox and that works but when I click add to create a second row the first textbox is named txtcalendar0 as well.
Any suggestions on how to get around this?? Please let me know if I should post the piece of code for this.
Thank you!
Illegal Operation
|
|
|
|
|
How are you generating the IDs? Post the code.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Here is the code as it works now. Everytime you click the add button it should just duplicate the existing row.
private int numOfRows = 1;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GenerateTable(numOfRows);
}
}
private void GenerateTable(int numOfRows)
{
Table tblTimesheet = new Table();
tblTimesheet.ID = "tblTimesheet";
placeHolder.Controls.Add(tblTimesheet);
const int colsCount = 12;
for (int i = 0; i < numOfRows; i++)
{
TableRow HeaderRow = new TableRow();
TableRow newRow = new TableRow();
for (int j = 0; j < colsCount; j++)
{
TableCell newCell = new TableCell();
newCell.HorizontalAlign = HorizontalAlign.Center;
TextBox txtWeekday = new TextBox();
txtWeekday.ID = "txtWeekday" + j;
txtWeekday.Width = 80;
CheckBox chkLunchCrib = new CheckBox();
chkLunchCrib.ID = "chkLunchCrib" + j;
chkLunchCrib.Checked = false;
if (txtWeekday.ID == "txtWeekday11" || txtWeekday.ID == "txtWeekday10" || txtWeekday.ID == "txtWeekday9")
{
txtWeekday.Visible = false;
}
if (chkLunchCrib.ID == "chkLunchCrib0" || chkLunchCrib.ID == "chkLunchCrib1" || chkLunchCrib.ID == "chkLunchCrib2" || chkLunchCrib.ID == "chkLunchCrib3" || chkLunchCrib.ID == "chkLunchCrib4" || chkLunchCrib.ID == "chkLunchCrib5" || chkLunchCrib.ID == "chkLunchCrib6" || chkLunchCrib.ID == "chkLunchCrib7" || chkLunchCrib.ID == "chkLunchCrib8")
{
chkLunchCrib.Visible = false;
}
#region Date Selection.
TextBox txtCalendar = new TextBox();
txtCalendar.ID = "txtCalendar" + j;
txtCalendar.Width = 155;
txtCalendar.Text = DateTime.Today.ToShortDateString();
ImageButton imgbtnCalendar = new ImageButton();
imgbtnCalendar.ID = "imgbtnCalendar";
imgbtnCalendar.ImageUrl = "~/Resources/Calendar_scheduleHS.png";
imgbtnCalendar.ImageAlign = ImageAlign.AbsMiddle;
AjaxControlToolkit.CalendarExtender ajaxCalExt = new AjaxControlToolkit.CalendarExtender();
ajaxCalExt.ID = "ajaxCalExt";
ajaxCalExt.TargetControlID = "txtCalendar" + j;
ajaxCalExt.PopupButtonID = "imgbtnCalendar";
#endregion
if (txtCalendar.ID == "txtCalendar0" && txtWeekday.ID == "txtWeekday0")
{
newCell.Controls.Add(txtCalendar);
newCell.Controls.Add(imgbtnCalendar);
newCell.Controls.Add(ajaxCalExt);
txtWeekday.Visible = false;
}
newCell.Controls.Add(txtWeekday);
newCell.Controls.Add(chkLunchCrib);
newRow.Cells.Add(newCell);
}
tblTimesheet.Rows.Add(HeaderRow);
tblTimesheet.Rows.Add(newRow);
}
numOfRows++;
ViewState["RowsCount"] = numOfRows;
}
protected void btnAdd_Click(object sender, EventArgs e)
{
if (ViewState["RowsCount"] != null)
{
numOfRows = Convert.ToInt32(ViewState["RowsCount"].ToString());
GenerateTable(numOfRows);
}
}
Illegal Operation
|
|
|
|
|
Illegal Operation wrote: for (int i = 0; i < numOfRows; i++)
Above loop will run number of times equal to the value of i. In this case
Illegal Operation wrote: "txtCalendar" + j;
will create the multiple target control id for ajaxCalExt.
You may try this, ajaxCalExt.TargetControlID = "txtCalendar" + j.ToString() + i.ToString();
|
|
|
|
|
Illegal Operation wrote: private void GenerateTable(int numOfRows)
{
Table tblTimesheet = new Table();
tblTimesheet.ID = "tblTimesheet";
placeHolder.Controls.Add(tblTimesheet);
.
.
.
As per the above lines, the Table tblTimesheet would be added to the place holder as many times as you click the Add row button.
You would need to change the logic to first check if the place holder already has a the desired table and based on availability you have to either create a new instance or get an handle to the existing instance and add rows. To do this you have to set the runat property of the table that you create to "server" so that the table is visible on the server after postback. You would also have to change the logic to add rows based on the above availability check.
Alternately you can clear the control array before you add the new table, but if you decide to do so then you'll have to ensure that you copy the data from the existing table's textboxes to the new table's textboxes.
For the replication logic for the date textbox you can use the logic suggested by arun$aini. In fact it would be advisable to do it for all the controls that you add to the table.
I assume you need to get the data from the textboxes/checkboxes on some submit button click. For that to happen you need to set the runat property of all the dynamically created controls too.
|
|
|
|
|
Hi,
I am having two iframes on a page, the top one contains a select box and the bottom one holds a aspx page depending on the selection of list item in the select box. So, it should always reload the bottom iframe whnever an item is changed in the selectbox and for that i am using reload() to reload the aspx page.
And the expected behavior is it should get refreshed (i.e. no postback)
But the acutal behavior happening in my case is its throwing this "to display the webpage again the IE needs to resend the information back ..." alert and when click on cancel or retry buttons on the alert its now doing a postback which is not expected.
If anybody have any clues, please post them
|
|
|
|
|
Please show me how you are doing the refresh operation.
|
|
|
|
|
this is how I am reloading the aspx in that frame.
top.pageContainer.location.reload()
One more thing, the problem is seen if there were any postbacks registered in the aspx page. I mean, it works as expected(reloads the page without postback) when there are no postbacks registered on the aspx page. But once a postback event is done on the aspx and try to reload the page it throws that message and postbacks. I thnk this is because, its caching that postback event.
But for now, i found the hack...
instead of doing a location.reload() i am doing this
top.pageContainer.location = top.pageContainer.location.href
as pointing to a new url (but pointing the same one)
this one solves the problem for now.
|
|
|
|
|
Hi,
I am working on a Asp.net application in this on button click I need to open a URL in a new browser window of height=300 and width=500.
If anyone have any idea to do this please reply me.
Thanks in Advance
|
|
|
|
|
|
you can use java script to do this.
|
|
|
|
|
use
javascript:window.open('url')
|
|
|
|
|
You can even use ASP.Net's LinkButton and set its property target to _blank
Please don't forget to mark 'Good Answer', if you find it really a good one!
Kashif
|
|
|
|